Glassfish在域身份验证中创建多个http会话

Glassfish在域身份验证中创建多个http会话,glassfish,httpsession,realm,Glassfish,Httpsession,Realm,我有一个关于领域身份验证的问题,glassfish在其中创建多个http会话。这里有一个例子 Web.xml: <security-constraint> <web-resource-collection> <web-resource-name>AllPages</web-resource-name> <url-pattern>/*</url-pattern> </web-res

我有一个关于领域身份验证的问题,glassfish在其中创建多个http会话。这里有一个例子

Web.xml:

<security-constraint>
    <web-resource-collection>
      <web-resource-name>AllPages</web-resource-name>
      <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
      <role-name>user</role-name>
    </auth-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>FileRealm</realm-name>
  </login-config>
<security-constraint>
}

}

当我进行身份验证时,glassfish将创建一个新会话:

信息:会话创建id:29c5d904db0e40b9cfbdac40aa5e

当我点击“回家”链接或刷新页面时,glassfish会创建另一个http会话:

信息:会话创建id:2a67270137e38c150bf3690e2e46

我还注意到glassfish从未破坏第一次创建的会话


谢谢你的帮助

这可能是一只玻璃鱼虫。 尝试使用以下选项将context.xml添加到META-INF目录:

<?xml version='1.0' encoding='utf-8'?>
<Context>
<Valve className="org.apache.catalina.authenticator.BasicAuthenticator"
changeSessionIdOnAuthentication="false" />
</Context>

或(在web表单验证的情况下):


这应该(暂时)解决你的问题

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome Page</title>
</head>
<body>
<p>You have successfully logged into the application.</p>
<a href="./home.jsp">go to home</a>
</body>
</html>
  System.out.println("Session destroyed id:"+arg0.getSession().getId());
<?xml version='1.0' encoding='utf-8'?>
<Context>
<Valve className="org.apache.catalina.authenticator.BasicAuthenticator"
changeSessionIdOnAuthentication="false" />
</Context>
<?xml version='1.0' encoding='utf-8'?>
<Context>
<Valve className="org.apache.catalina.authenticator.FormAuthenticator"
changeSessionIdOnAuthentication="false" />
</Context>