delete cookie when browser closed
<p>i need to delete cookie when browser is closed and already put on window.onbeforeunload along with other as following:</p>

<pre><code> window.onbeforeunload = function(){
        location.replace("admin.jsp?action=logout");
        deleteCookie('Times');
 }
</code></pre>

<p>with setCookie as following:</p>

<pre><code> function setCookie(name,value,days) {
         var expires;
         if (days) {
                  var date = new Date();
                  date.setTime(date.getTime()+(days*24*60*60*1000));
                  expires = "; expires="+date.toGMTString();
         }
         else {
                  expires = "";
              }
                  document.cookie = name+"="+value+expires+"; path=/";
     }
</code></pre>

<p>when it comes to deleteCookie, it contains as below:</p>

<pre><code>    setCookie(name,value,-1);
</code></pre>

<p>The problem is whenever i restart browser, it always comes to window.onbeforeunload so that deleteCookie fired. I actually need this to reset my countdown timer whenever user logs in since the cookie never deleted if the counter doesn't end and user sometimes closes window/tab before it ends. So, my idea is either reset the counter when user logs in or simply delete cookie when user logs out. I still can't figure out how to code this, however. Can anyone help me out? Code snippet will be appreciated, though. CMIIW</p>
