title: Logout Page in AngularJS
body: <p>I am facing an issue with logout page.when logout option is clicked from a page,  the login page has to be loaded and even when the user tries to click previous page arrow in browser, only the login page has to be displayed. I have tried using <code>$window.location.reload();</code>and<code>sessionStorage.clear();</code> which didnt give the solution.</p>
  
  <p>Right now I have logout page which displays login page but when back page is clicked all the details of previous logged in user are available. Below is the code:</p>
  
  <p>index.html:</p>
  
  <pre><code>&lt;body ng-app="app"&gt;
   &lt;div class=" "&gt;
      &lt;div ui-view&gt;&lt;/div&gt;
   &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>login.html:</p>
  
  <pre><code> &lt;form ng-submit=submit()&gt;
     &lt;input type="text" name="username" placeholder="Username" ng-model="person.firstName" required /&gt;
     &lt;input type="password" name="pswd" placeholder="Password" ng-model="person.pswd" required /&gt;
         &lt;div class="submit"&gt;
            &lt;input type="submit" value="LOGIN"&gt;
          &lt;/div&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>page.html:</p>
  
  <pre><code>&lt;ul&gt;
   &lt;li&gt;&lt;a ui-sref="logout"&gt;Logout&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>app.js:</p>
  
  <pre><code>var app = angular.module('app', ['ui.bootstrap', 'LocalStorageModule']);
  app.config(function ($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise('/login');
  $stateProvider
            .state('page', {
               url: '/page/:id',
              templateUrl: 'page.html'
                 })
           .state('login', {
               url: '/login',
               templateUrl: 'login.html',
               controller: 'LoginCtrl'
           })
           .state('tab', {
            url: '/tab/:id',
           templateUrl: 'views/tab.html'
              })
       .state('logout', {
           url: '/logout',
           templateUrl: 'logout.html',
           controller: 'LogoutCtrl'
       });
       });
  app.controller('LogoutCtrl', function ($scope, $http, $location, $state) {
  sessionStorage.clear();
  $location.path('/login');
  //this is loading login page, but if back arrow is clicked previous logged in details are present//
  });
  app.controller('LoginCtrl', function ($scope, $http, $location, $state) {
    $scope.submit = function () {
        $http.get("url" + $scope.Name + "&amp;Password=" + $scope.pswd)
         .success(function (data, status, headers, config) {
             debugger
             $scope.tableData = data;
             console.log(data)
             if (data == 'Exception') {
                 window.alert('You have entered wrong username or password');
  
             }
             else $state.go('tab', { id: data.Table[0].UserId });
         })
  
  }
  });
  </code></pre>
  
  <p>In brief what I need is: After logging out, login page has to be displayed and if user tries to go to back page, then also login page alone has to be displayed.</p>
  
  <p>Would be grateful if anyone can help.</p>