title: When does JavaScript session expire? How to delete cookie on session end?
body: <p>I would like to delete the cookie named "username" once the user closes their tab/browser. I am using the following code to detect if user closes and cookie should be deleted. But cookie is still there. Why?</p>
  
  <p>In browser console resources, it shows cookie expiry field as "session". When does a session end?</p>
  
  <pre><code>// delete cookies when user closes browser/tab
  $(window).unload(function() {
     $.removeCookie('username', { path: '/' });
  });
  </code></pre>