How to achieve the role played by "public static variables of Java" in JavaScript or a webpage?
<p>On my homepage I have to set a cookie using the name of the logged in user. The cookie <code>set</code> and <code>get</code> part has to be done in JS. On the subsequent sub pages I have to retrieve the <code>cookie(username)</code> using the <code>set</code> variable name. </p>

<p>How can I store the username/cookie name so that it is publicly accessible across all the pages? This username will obviously change with each new user and is not constant.</p>

<p>I have tried doing this using external JS file but in every new page the value is reset to default which I don't want.</p>

<p>The exact solution to my problem is like the work done by:</p>

<pre><code>public static variable
</code></pre>

<p>in Java (not final). I want to achieve this in JS.</p>
