Changing the value of a cookie not working
<p>I have a method of tracking the download of a document using a <code>cookie</code>.</p>

<p>When the download of the document is complete the <code>cookie</code> is set to 'complete' using <code>php</code> using:</p>

<pre><code>&lt;?php
.... document created ...
setcookie("download", "complete", time() + (86400), "/"); // 86400 = 1 day
?&gt;
</code></pre>

<p>This works and the <code>cookie</code> is set to 'complete'.</p>

<p>A javascript listener on the initial page is checking the <code>cookie</code> so that when it is set to 'complete' the loading gif will be hidden, and then reset the <code>cookie</code>:</p>

<pre><code>&lt;script&gt;
    window.setInterval(function () {
        var cookie = $.cookie('download');  

        if (cookie !== null) {
            if (cookie == 'complete') {
                $(".loader").hide();
                    document.cookie = "download=waiting"; 
            }
        }

    }, 500); 
&lt;/script&gt;
</code></pre>

<p>The loading gif disappears but the <code>cookie</code> does not change value. I have tried a number variations such as to delete it:</p>

<pre><code>document.cookie = "download=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
</code></pre>

<p>but nothing seems to work. I suspect it is the format of the <code>cookie</code> is a little different when set with my <code>php</code> and then trying to change it in <code>javascript</code>. Any pointers?</p>

<p>UPDATE:</p>

<p>It seems this is working:</p>

<pre><code>document.cookie = "download=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
</code></pre>