In my system, 开发者_如何转开发after user login the page, I want to generate a new http session id without close internet explorer.
I write the code like this:
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
HttpSession session = request.getSession(true);
System.out.println("session id:"+session.getId());
session.invalidate();
deleteCookie( request.getCookies(),request,response);
session = request.getSession();
System.out.println("new session id:"+session.getId());
}
private void deleteCookie(Cookie[] cookies,HttpServletRequest req,HttpServletResponse response){
logger.debug("Delete cookie");
int cookieLenght = cookies.length;
for (int i = 0; i < cookieLenght; i++) {
Cookie cookie = cookies[i];
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);
}
}
Even I invalidate the session , delete the cookie ,get a new session, but the session Id is still the same. I do not know why. Is there any solution to generate a new session id without close the internet Explorer?
精彩评论