如何清除angularjs中的cookie?

时间:2021-09-24 19:46:11

i am using a web service having basic authentication i.e. below code shows how i calling the web service

我正在使用具有基本身份验证的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;
              }
          }).

i am getting the correct response and all working fine. But when i logout the app i am using the below code

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

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

the real problem is when i logedout then try to logged in with incorrect password it getting logged in web service retuning the previous user details.how can i fix this one thanks in advance?

真正的问题是当我logedout然后尝试使用不正确的密码登录它登录web服务重新调整以前的用户详细信息。我可以提前解决这个问题吗?

1 个解决方案

#1


Just to answer your question:

只是回答你的问题:

remove cookies and header, then it asks for re-authentication and also clear native application then it is working fine

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

#1


Just to answer your question:

只是回答你的问题:

remove cookies and header, then it asks for re-authentication and also clear native application then it is working fine

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