Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am beginning to wonder if your testing method might be the problem here. So, I am going to write this in a specific way. </p> <h3>Actual Answer: Browser Setting</h3> <p>In Firefox, Options>General>When Firefox starts>"Show my windows and tabs from last time" is going to preserve your previous session. Change this setting to see that this is indeed working as it is supposed to. Firefox is prolonging your session. For further information, see this "bug": <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=530594" rel="nofollow">http://bugzilla.mozilla.org/show_bug.cgi?id=530594</a></p> <p>There are similar settings in most browsers that probably behave the same way. <hr></p> <h2>Original Answer:</h2> <p>I created a fiddle, <a href="http://jsfiddle.net/8Ahg2/" rel="nofollow">http://jsfiddle.net/8Ahg2/</a> that uses document.cookie rather than jquery cookie plugin. Here is how you test this. (source below)</p> <ol> <li>copy the following URL to your clipboard: <code>http://fiddle.jshell.net/8Ahg2/show/</code></li> <li><strong>Completely</strong> close your browser of choice - this should be browser independent.</li> <li>Open your browser, paste the url. The first time it should say: <code>check cookie... set cookie...</code></li> <li>Refresh the page, notice that it should now say the value of the cookie ("test")</li> <li>Close your browser <strong>completely</strong> again.</li> <li>Navigate to the URL that should still be in your clipboard. <strong>*Do not refresh the page</strong> on the first view, it should again say '<code>check cookie... set cookie...</code>'</li> </ol> <p><hr></p> <h3>js</h3> <pre><code>$(document).ready(function () { $('#output').append('&lt;li&gt;initialize...&lt;/li&gt;'); //this regex gets the "name" cookie out of the string of cookies that look like this: "name=test;var2=hello;var3=world" var cookieVal = document.cookie.replace(/(?:(?:^|.*;\s*)name\s*\=\s*([^;]*).*$)|^.*$/, "$1"); $('#output').append('&lt;li&gt;check cookie...&lt;/li&gt;'); if (!cookieVal) { $('#output').append('&lt;li&gt;set cookie...&lt;/li&gt;'); document.cookie = "name=test"; } else { $('#output').append('&lt;li&gt;cookie is already set...&lt;/li&gt;'); $('#output').append('&lt;li&gt;cookie value: ' + cookieVal + '&lt;/li&gt;'); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload