Read a variable from a variable cookie jquerycookie.

Posted by Ozaki on Stack Overflow See other posts from Stack Overflow or by Ozaki
Published on 2010-05-04T02:32:20Z Indexed on 2010/05/04 2:38 UTC
Read the original article Hit count: 341

TLDR How could I tell "page.html" which one of 3 or so cookies to look at when the cookie is set on the previous page?


Currently:

  1. When a link is clicked save text of link to cookie
  2. When "page.html" is loaded get the value of the cookie
  3. Loads the getjson call as per value of the cookie.

E.g:

<a href="page.html">link1</a> -c1
<a href="page.html">link2</a> -c2
<a href="page.html">link3</a> -c3

See previous discussion here


Now that is all good and well apart from the fact if I were to say open them in multiple tabs. It changes the cookie and correctly loads the right data. But if I were to refresh one of these tabs it will load the most recently open data rather than what it should be.

So if I were to save a cookie as

c1 with a value of link1

c2 with a value of link2

c3 with a value of link3

How could I tell "page.html" which cookie it should be looking at, therefore not breaking the back/forward/refresh buttons on the browser when multiple tabs are open?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery