ojus kulkarni ojus kulkarni - 6 months ago 493
AngularJS Question

clear cookies while logout in spring security or in angular

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

Answer

After going through many blogs on spring security I got answer,

.invalidateHttpSession(true) :- it is used to clear our session
and
.deleteCookies("JSESSIONID") :- it is used to delete cookies

use this after your success handler so that it will remove all cookies after logout