在此之后,您不会刷新,而在之前。首先执行登录操作时,请执行以下操作:
HttpSession session = request.getSession(false);
if (session!=null && !session.isNew()) {
session.invalidate();
}
然后做:
HttpSession session = request.getSession(true); // create the session
// do the login (store the user in the session, or whatever)
仅供参考,您要使用此技巧解决的问题是http://www.owasp.org/index.php/Session_Fixation
最后,您可以禁用自动会话创建,仅在真正需要时创建会话。如果您使用JSP,则可以通过以下方式进行操作:
<%@page contentType="text/html"
pageEncoding="UTF-8"
session="false"%>