clear cookies while logout in spring security or in angular

时间:2016-05-13 15:36:02

标签: angularjs spring cookies spring-security

My trial code to remove cookies

.logout()
.logoutUrl("/access/logout")
.logoutSuccessHandler(new LogoutSuccessHandler() {
 @Override
public void onLogoutSuccess(
HttpServletRequest request,
HttpServletResponse response,
Authentication a) throws IOException, ServletException {
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
  }
})
.deleteCookies("JSESSIONID")
.invalidateHttpSession(true)

This is code of logout security with HttpSecurity
Here i am getting issue to delete cookies
in logoutSuccessHandler in logger it shows cookies = 1 and i.e JESSESIONID
So my problem is how to delete cookie at the time of logout
or if is there any another way or any way in angular then please tell me

1 个答案:

答案 0 :(得分:1)

经过许多关于春季安全的博客后,我得到了答案,

.invalidateHttpSession(true): - 用于清除会话

.deleteCookies("JSESSIONID"): - 用于删除Cookie

在成功处理程序之后使用它,以便在注销后删除所有cookie

修改

如果有人想要从前端处理cookie,那么你可以使用AngularJs中的ng-cookies来处理它。