The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
I'm having a little trouble figuring out how to extract information stored in a cookie.
The cookie contains multiple values, each separated by a comma (,) but isn't splitting as I'd like it.
The cookie reads as: "visits=page1=19,page2=7,page3=16,page4=12" (where 'visits' is the cookie name and
'page1=19,page2=7,page3=16,page4=12' is the cookies value)
I've already used the split(";") method to break up multiple cookies, but now I want to break up the cookie name and value into two stores so the values would be stored like so:
cookie[0] = "visits";
cookie[1] = "page1=19,page2=7,page3=16,page4=12";
At which point I would use split(","); to break up each individual page hit.
However, I am only able to get as far as using the split method to break up the string at each '=', rather than just the first, so the results appear as:
cookie[0] = "visits";
cookie[1] = "page1";
cookie[2] = "19,page2";
cookie[3] = "7,page3";
cookie[4] = "16,page4";
cookie[5] = "12";
This makes using the values a lot harder.
I'm a little rusty with strings when it comes to JavaScript, so I am wondering if anyone can give me the code which will split up the cookie string by the first '=' sign, and only the first one??
Any help is appreciated.
I'm having a little trouble figuring out how to extract information stored in a cookie.
The cookie contains multiple values, each separated by a comma (,) but isn't splitting as I'd like it.
The cookie reads as: "visits=page1=19,page2=7,page3=16,page4=12" (where 'visits' is the cookie name and
'page1=19,page2=7,page3=16,page4=12' is the cookies value)
I've already used the split(";") method to break up multiple cookies, but now I want to break up the cookie name and value into two stores so the values would be stored like so:
cookie[0] = "visits";
cookie[1] = "page1=19,page2=7,page3=16,page4=12";
At which point I would use split(","); to break up each individual page hit.
However, I am only able to get as far as using the split method to break up the string at each '=', rather than just the first, so the results appear as:
cookie[0] = "visits";
cookie[1] = "page1";
cookie[2] = "19,page2";
cookie[3] = "7,page3";
cookie[4] = "16,page4";
cookie[5] = "12";
This makes using the values a lot harder.
I'm a little rusty with strings when it comes to JavaScript, so I am wondering if anyone can give me the code which will split up the cookie string by the first '=' sign, and only the first one??
Any help is appreciated.