HttpSession 对象如何绑定到浏览器? [英] How does the HttpSession object get bound to the browser?

查看:67
本文介绍了HttpSession 对象如何绑定到浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Tomcat7 中使用负载平衡器,现在我们的 HttpSession 对象总是返回一个新会话.我的猜测是将浏览器绑定到服务器的信息没有发送到服务器.

I'm using a load balancer with Tomcat7 and right now our HttpSession object always returns a new session. My guess is that the information that binds the browser to the server isn't being sent to the server.

会话是否由 cookie 客户端中设置的令牌映射?如果是这样,这是在每个请求的 HTTP 标头中发送的吗?如果是这样,它看起来像什么?

Is the session mapped by a token set in a cookie client-side? If so, is this sent in the HTTP header with each request? And if so, what does it look like?

推荐答案

每次最初连接到服务器时,都会生成一个 jsessionid 并将其保存到客户端的 cookie 中.该 jsessionid 是在服务器上标识您的会话的内容.因此,HttpSession 对象是在服务器端生成的,它包含您的特定会话的所有详细信息,直到它过期.是的,每次向服务器发送请求时都会发送 jsessionid.阻止这种情况的唯一方法是浏览器不允许保存 cookie.在这种情况下,还有其他机制可以确保保留 jsessionid.无论如何,这是我对过程的理解.希望这可以帮助.

Every time you connect to the server initially a jsessionid is generated and saved to a cookie on the client side. That jsessionid is what identifies your session on the server. So, HttpSession object is generated on the server side which contains all the details of your particular session until it expires. Yes the jsessionid is sent every time you send a request to the server. The only way this is thwarted is if the browser isn't allowing the saving of cookies. In which case, there are other mechanisms that can still ensure that the jsessionid is retained. That's my understanding of the process anyway. Hope this helps.

这篇关于HttpSession 对象如何绑定到浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆