Javascript cookies

by Ramya 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();

Tagged in:

848
like
0
dislike
0
mail
flag

You must LOGIN to add comments