I'm working on this code that uses a JS cookie to figure out what submenus are expanded/collapsed on a JS menu.
I can read and write the cookie just fine on that particular page.
If I surf to another page which I've never visited before (within the site and using that cookie of course), the menu reads the cookie just fine and the code acts correctly. If I visit a page that has been visited before, it overwrites the cookie that I set on the page before (onunload) and instead reads that values from the cookie that I originally came there with.
In other words, let's say I set a cookie with a value of 4 on a page (page1). I got to another page (page2) that reads the cookie and I get 4. I come back to page1 and set the cookie to 152. I go back to page2 and the cookie value is overwritten to 4.
Why? Any ideas?