您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

登录后如何刷新JSESSIONID cookie

登录后如何刷新JSESSIONID cookie

在此之后,您不会刷新,而在之前。首先执行登录操作时,请执行以下操作:

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"%>
其他 2022/1/1 18:22:40 有481人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶