title: how to clear devise session on browser close?
body: <p>I am using 'devise' for password authentication in my ruby on rails app. Once I successfully login and I close my browser and open a new browser window I am still logged in. Lets say I am using Chrome, I close all instances of chrome and then open a new one. I am still logged in. The same is the case when I am doing IE and Firefox too.</p>
  
  <p>I would assume on close of window and opening a new window should establish a new session between the server and the browser isn't it? If not how do I achieve that?</p>
  
  <p>i used tried doing clicking on logout button on browser window's <code>onbeforeunload</code> event, but it does not works as it logout of application on any form submit or link click.  </p>
  
  <pre><code>window.onbeforeunload = function() {
    $('#logout_cls').click();
  };
  </code></pre>
  
  <p>and tried sending <code>AJAX</code> request to the sessions controller destroy action for clearing the session.</p>
  
  <pre><code>  jQuery(window).bind(
      "close",
      function(event) {
            $.ajax({
              type: 'DELETE',
              dataType: 'json',
              url: $('#logout_cls').attr('href')
            });
      });
  </code></pre>
  
  <p>but all this did not work.</p>