简体   繁体   English

如果浏览器存储了cookie和jsessionid,则在URL中传递jsessionid

[英]jsessionid passed in url if cookie and jsessionid stored by browser

My web application was passing jsessionid in URL while it was using cookie base session management in other browser and machine which is desired behavior. 我的Web应用程序在其他浏览器和计算机中使用cookie基本会话管理时,正在通过URL传递jsessionid,这是理想的行为。

To fix this issue, I deleted stored cookie and jsessionid from locale storage and then it start using cookie base session management instead of URL rewriting. 为了解决此问题,我从区域设置存储中删除了存储的cookie和jsessionid,然后开始使用cookie基本会话管理而不是URL重写。

Can someone explain why this is happening, stored cookie and jsessionid stopping application to use cookie base management.I need only cookie base session management in application how I can do that. 有人可以解释为什么会这样吗,存储的cookie和jsessionid会阻止应​​用程序使用cookie基础管理。我只需要在应用程序中执行cookie基础会话管理即可。

Environment: 环境:

Chrome browser, Struts 2,Tomcat 7,Java 8 Chrome浏览器,Struts 2,Tomcat 7,Java 8

Thank in advance. 预先感谢。

jsessionid is special cookie used by Java application/web server to track user's session (to recognize user is old user eg. who has already logged in). jsessionid是Java应用程序/ Web服务器用来跟踪用户会话的特殊cookie(以识别用户是旧用户,例如已经登录的用户)。 For the first request to the server there will not be any cookies sent by the browser. 对于对服务器的第一个请求,浏览器将不会发送任何cookie。 So, server do not know whether the client supports cookie or not. 因此,服务器不知道客户端是否支持cookie。 For this server sends the jsessionid in cookie and in URL (URL Rewriting). 对于该服务器,在cookie和URL(URL重写)中发送jsessionid But for the next request onwards the cookie will be available (from the previous request browser will store the cookie sent by the server and for the same context now it knows there is already it has cookie, so send it). 但是对于接下来的下一个请求,cookie将可用(从上一个请求中,浏览器将存储服务器发送的cookie,并且对于相同的上下文,它现在知道已经具有cookie,因此将其发送)。 That is why for next request onward you do not see jsessionid in URL. 这就是为什么对于下一个请求,您在URL中看不到jsessionid的原因。 To force the server only use COOKIE based tracking, you will have add below fragment in web.xml 要强制服务器仅使用基于COOKIE的跟踪,您将在web.xml添加以下片段

<session-config>
  <!-- Only cookie based tracking -->
  <tracking-mode>COOKIE</tracking-mode>
</session-config>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM