my javascript cookie works for my show and hide, but doesn't work for my toggle? <p>I have a cookie that remembers if my drop down is hidden or visible or not. Then I added a image to the drop down, and toggling the the photos also, but the cookie doesn't seem to remember what state the toggle is in.</p> <pre><code>&lt;script type="text/javascript"&gt; &lt;!-- var state; var stateTog; window.onload = function () { obj = document.getElementById('featured'); state = (state == null) ? 'hide' : state; obj.className = state; document.getElementById('featured-header').onclick = function () { var option = ['tel1', 'tel2']; for (var i = 0; i &lt; option.length; i++) { objTog = document.getElementById(option[i]); objTog.className = (objTog.className == "visible") ? "hidden" : "visible"; } obj.className = (obj.className == 'show') ? 'hide' : 'show'; state = obj.className; stateTog = objTog.className; setCookie(); return false; } } function setCookie() { exp = new Date(); plusMonth = exp.getTime() + (31 * 24 * 60 * 60 * 1000); exp.setTime(plusMonth); document.cookie = 'State=' + state + ';expires=' + exp.toGMTString(); document.cookie = 'StateTog=' + stateTog + ';expires=' + exp.toGMTString(); } function readCookie() { if (document.cookie) { var tmp = document.cookie.split(';')[0]; state = tmp.split('=')[1]; stateTog = tmp.split('=')[1]; } } readCookie(); //--&gt; &lt;/script&gt; </code></pre>