我有这个问题。当我尝试从应用程序注销时,会话无效并且 它被删除了 但是,如果我比注销之前更早地更改了该idsession,则(注销后)将站点更改为coppeded sessionId,并且应用程序可以正常工作。我想避免这种情况。
这就是我的logout.jsp中的内容
简而言之,关键是不能在应用程序中使用旧会话
我将竭诚为您服务。
<%
//clear cookies
Cookie[] cookies = request.getCookies();
if(cookies != null){
for (Cookie cookie : cookies) {
cookie.setMaxAge(0);
cookie.setValue(null);
cookie.setPath("/");
response.addCookie(cookie);
}
}
// remove all sessionAttributes
try {
while (request.getAttributeNames().hasMoreElements()) {
String key = request.getAttributeNames().nextElement().toString();
System.out.println(
" WebUtil chearCache key:{}" + key + ": " + request.getAttribute(key));
request.removeAttribute(key);
System.out.println(" aip WebUtil removeAttribute key:{}" + key);
}
} catch (Exception e) {
System.out.println(" chearCache error {}" + e.getMessage());
e.printStackTrace();
}
//preventing cache
response.setHeader("Cache-Control","no-cache"); //Forces caches to obtain a new copy of the page from the origin server
response.setHeader("Cache-Control","no-store"); //Directs caches not to store the page under any circumstance
response.setDateHeader("Expires", 0); //Causes the proxy cache to see the page as "stale"
response.setHeader("Pragma","no-cache"); //HTTP 1.0 backward compatibility
// delete session
request.getSession(false).invalidate();
%>