How do I implement jQuery Sidebar and Cookies
<p>I have setup a sidebar via the jQuery API. Now I noticed that when I refresh the page, the sidebar is going to close itself automatically.</p>

<p>I found a cookie thing on the internet but for some reason it does not work with my sidebar script.</p>

<p>What am I doing wrong?</p>

<pre><code>$(document).ready(function() {
    var sidebar_status = $.cookie("sidebar_status");

    if (sidebar_status == null) {
        $("a#ToggleSidebar").addClass('closed');
        $("#sidebar").hide();
    };

    if (sidebar_status == "closed") {
        $("a#ToggleSidebar").removeClass('open');
        $("a#ToggleSidebar").addClass('closed');
        $("#sidebar").css("display", "none");
    };

    if (sidebar_status == "open") {
        $("a#ToggleSidebar").addClass('open');
    };


    $("a#ToggleSidebar").click(function() {
        if ($("a#ToggleSidebar").attr("class") == 'open') {
            $(this).removeClass('open');
            $(this).addClass('closed');
            $.cookie("sidebar_status", "closed", {
                path: '/',
                expires: 100
            });
            $("#sidebar").animate({
                width: 'hide',
                opacity: 'hide'
            }, 'slow');
        } else {
            $(this).removeClass('closed');
            $(this).addClass('open');
            $.cookie("sidebar_status", "open", {
                path: '/',
                expires: 100
            });
            $("#sidebar").animate({
                width: 'show',
                opacity: 'show'
            }, 'slow');
        }
    });
</code></pre>

<p><strong>EDIT:</strong></p>

<p>There is something like a button <code>&lt;a href="#"&gt;&lt;/a&gt;</code> which should open a <code>&lt;div&gt;&lt;/div&gt;</code>. Now, I expect that when somebody visits the page the first time, that the <code>&lt;div&gt;&lt;/div&gt;</code> is closed. When the user clicks on the <code>&lt;a href="#"&gt;&lt;/a&gt;</code> it opens the <code>&lt;div&gt;&lt;/div&gt;</code> and saves a cookie. When the user should now refresh the page, the <code>&lt;div&gt;&lt;/div&gt;</code> should stay open until the user uses the <code>&lt;a href="#"&gt;&lt;/a&gt;</code> to close it again. That is what I can not get to work.</p>
