Javascript cookies
by Ramya[ Edit ] 2010-01-28 18:18:20
Javascript Cookies:
Cookies are small text files stored in your browser. Cookies can be read by JavaScript too.
Javascript Cookies contains some data:
1. A name-value pair containing the actual data
2. An expiry date after which it is no longer valid
3. The domain and path of the server it should be sent to
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
Example:
var expires = new Date();
expires.setDate(expires.getDate() + 7); // 7 = days to expire
document.cookie = "name=test;expires=" + expires.toGMTString();