如何清除angularjs中的cookie?

时间:2015-05-07 10:45:47

标签: angularjs http-headers ionic-framework session-cookies httpcookie

我正在使用具有基本身份验证的Web服务,即下面的代码显示我如何调用Web服务

var url='http:url.com/;
      $http.defaults.headers.common['Authorization'] = 'Basic ' + Base64.encode(Username + ':' + password);
      $http({method: 'GET', url: url}).
          success(function(data) {
              if(data=='' || data==null || data=='undefined'){
                  var alertPopup = $ionicPopup.alert({
                      title: 'Info!',
                      template: 'Invalid Password, or no user found with this Email Address'
                  });
                  alertPopup.then(function(res) {
                      console.log('Invalid Password, or no user found with this Email Address ');
                  });
                  return false;
              }
              else{
                  var favoriteCookie = $cookies['JSESSIONID'];

                  window.localStorage['data'] = JSON.stringify(data);
                  //console.log("LOGIvar: " + data+ " - PW: " + password);
                  console.log(data);
                  $state.go('app.tasklists');
                  return false;
              }
          }).

我得到了正确的答复,一切正常。 但是当我退出应用程序时,我正在使用以下代码

 $cookieStore.remove('JSESSIONID');
  $cookieStore.remove('JSESSIONIDSSO');
  $http.defaults.headers.common['Authorization']='undefind';
  $scope.modal.show();
  $state.go('login',{}, {reload: true});

真正的问题是,当我匆匆忙忙然后尝试使用不正确的密码登录时,它会登录网络服务重新调整之前的用户详情。我可以提前解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

回答你的问题:

删除cookie和标题,然后它要求重新验证并清除本机应用程序然后它正常工作

相关问题