Skip to main content

Posts

Showing posts with the label Cookies

How to set Javascript Cookie for Domain

var cookie_date = new Date ( ); // current date & time cookie_date.setTime ( cookie_date.getTime() + 24*60*60*1000 ); // for 1 days Syntax: document.cookie = "CookieName=CookieValue; expires=cookie expire time"; path= directories;domain=domainname"; Example: document.cookie="test=testValue;expires="+ cookie_date.toGMTString()+";path=/dir1/dir2/dir3/;domain=mytest.com";

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