title: AngularJS reload page function and automatic log out conflict each other
body: <p>I am writing an app that uses <code>AngularJS</code> and <code>ui-router.</code> I have a button that refreshes the page by reloading the page, and the functionality that automatically logs users out when the window or tab is closed. Now both functions work awesome (and done using traditional javascript to make things simple). See below: </p>
  
  <pre><code>&lt;script&gt;
        // Refreshes by reloading page
        function refresh() {
            location.reload();
        }
  
        // Automatically logs users out when browser or tab is closed
        window.onunload = function(){
            localStorage.clear();
        }
  &lt;/script&gt;
  </code></pre>
  
  <p>However, the problem is when the reload button is clicked it also logs the current user out and this is not what I want. I only want the user to be logged out when the window is closed. Is there anyway this can be done? Will reloading the route in my controller fix the problem?</p>