I am trying to clear my all browser cookies from my code trying both from client side (JavaScript) and Server side (Java) individually. But I can't reach my goal.
I have gone through the several question and answer of stackoverflow as well as other site. But doesn't help me more. One question's answer works as description. The description is given below and question is here Delete all Cookies of browser using javascript.
You cannot delete cookies via Javascript that come from other domains than the page you are currently on. This is a browser security feature.
and another line is.
The only way to clear all cookies is for you (the user) to use the browser's user interface to delete the cookies or to configure your browser to automatically clear cookies when you close the browser.
what I tried from server side that is.
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
cookie.setValue("");
cookie.setPath("/path");
cookie.setMaxAge(0);
cookie.setHttpOnly(true);
response.addCookie(cookie);
}
}
Any help or any suggest will be appreciated to clear the all cookies from browser with out clearing it from the browser interface or closing the browser.