Skip to main content

JavaScript Cookies Functions

Java Script Cookies Set and Get functions

There are four function which is useful to work with javascript cookies. there are no predefine function in javascript so that we can use these function to work with browser cookies. here is description of functions.

1) Javascript function set_cookie(name,value) :- This is a void function take two parametters name & value. name param is used for cookies name & value is used to set cookies value.

2) Javascript function get_cookie(name) :- This string function, which return value of that particualr cookie which you pass as param.

3) Javascript function is_cookie(name) :- This is boolean function, which return true or false for cookies existence.

4) javascript function delete_cookie(name) :- This is a void function which is used to delete cookies. name param takes name of cookies which you want to delete.


<Script Language="javascript">

function set_cookie(name,value){
var name=name.toLowerCase();
document.cookie=name+"="+value;
}

function is_cookie(name){
var name=name.toLowerCase();
var str=document.cookie.indexOf(name+"=");
if(str>=0){
return true;
}else{
return false;
}
}

function get_cookie(name){
var name=name.toLowerCase();
var str="";
if(is_cookie(name))
{
var cStr=document.cookie.split(";");
for(var i=0;iif(cStr[i].indexOf(name)>=0){
str=cStr[i].substring(cStr[i].indexOf("=")+1,cStr[i].length);
}
}
}else{
str="";
}
return str;
}

function delete_cookie(name){
var name=name.toLowerCase();
set_cookie(name,'');
}
set_cookie("color","green");
document.bgColor=get_cookie("color");

</Script>

Comments

Popular posts from this blog

Flex Interview Questions

1) What is Flex? Flex is used to devleop Rich Internet Application (RIA) You can both desktop & web based applicaiton.It is markup language and object-oriented languages its many syntax match with flash action script. Flex Developers use typically five distinct phases to develoep Rich Internet Application. Design Configure Build Deploy Secure 2) How do i get Page URL and Query String ? We can use mx.core.Application.application.url (mx.core)package to work with current page URL. & query string. 3) Describe flex component file types ? There are following file types we can use in flex. extension .mxml - a component implemented as an MXML file. extension .as - a component implemented as an ActionScript class. extension .swc - a SWC file contains components in a packge. 4) Difference between target & currentTarget ? target : This property is set by the dispatchEvent() method. You cannot change this to a different object. currentTarget : This property is set by component instan...

Free Online Meta Tag Creator

Meta Tags are HTML header part tags, which describe about the website . These meta tags provide information to the search engines such as Google, Yahoo, MSN Search, AOL Search, AltaVista ,HotBot, Lycos, Excite and other search engines . It is very important to the search engine point of view meta tags must be well formed and meaningful . HTML Meta tags help to increase your website rank. The common questions arise for meta tags are as follows? What Are META Tags? META Tags are HTML header part tags of HTML Document that provide internal & external information about the content of a web page or website while you are browsing that page you are not able to see that Meta tags on your browser output. How META Tags Work for Search Engine? Meta tag tell to search about the page such as keywords, Description, Content Language etc, which parameter you put in contents attribute of the meta tags that's is read by search engine to index your page with accuracy, which is totally depend to...