|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionAny web programmer will have good tools to manipulate, read, and write query strings and cookies on the server side. A while back, when trying to utilize this information on the client side, I found the available JavaScript functions cumbersome for retrieving and "storing" multiple pieces of cookie and query string data. They lacked what the server side model has, which is an associative array to retrieve cookie and query string key/value pairs. So I developed the two classes Using the codeInstantiate global instances of these classes and initialize them: window.gCookies = new Cookies();
window.gQueryString = new QueryString();
gCookies.Read();
gQueryString.Read();
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 ( myQueryString.Clear();
myQueryString.SetValue("workspaceId", workspaceId);
...
myLink.href = document.location.pathname +
myQueryString.ToString();
The gCookies.SetValue("", "MyIntegerOption", 1);
gCookies.SetValue("", "MyCookieToExpire", null)
gCookies.Write();
History
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||