Using the code
Instantiate global instances of these classes and initialize them:
window.gCookies = new Cookies();
window.gQueryString = new QueryString();
Retrieving some sample data from these objects:
var iObjId = parseInt(gCookies.GetValue("","myObjId"));
var reportId = gQueryString.GetValue("reportId");
These data structures can store and retrieve data safely until it is later utilized by writing out the cookie to the document (
Write method), or reassembling the query string (
ToString method) and navigating to another page with it.
myLink.href = document.location.pathname +
QueryString class is emptied of all key/values by calling the
Clear method. The
Cookie class does not have a clear
Clear method. To destroy a cookie, you must set its value to
null, and once
Write() is called, it will be forced to expire.
gCookies.SetValue("", "MyIntegerOption", 1);
gCookies.SetValue("", "MyCookieToExpire", null)
- Article created - 4/17/06.