浏览器如何维护会话cookie
嘿,我试图创建一个java程序,每当我浏览网站时,该程序都会在服务器上保持登录状态,即使我稍后运行该程序,也不需要身份验证,即我的程序应该在客户端存储一些cookie文件,并告诉浏览器认为此会话应该持续相当长的时间。每当我运行该程序时,它都应该将 cookie 详细信息(该信息已被识别并且用户已登录)发送到服务器。
那么这应该如何使用 HTTP 协议来完成。
谢谢。 :)
Hey all I was trying to create a java program which will remain logged in on server whenever i browse on website no authentication will be required even if i run the program later on i.e. my program should store some cookie file on client side and also tell the browser that this session should lasts for quite a long time. And whenever i run the program this should send the cookie details, that this is recognized and the user is logged on, to the server.
So how this should be done using HTTP protocol.
Thanks. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
浏览器(客户端)存储包含键值对的会话cookie。键通常是 JSESSIONID,值是唯一标识符。客户端接收到它作为其对服务器的请求的响应,服务器启动会话。
每当向服务器发出请求时,浏览器都会在特殊的 http 标头(“Cookie”)中发送该键值对。然后,服务器读取该标头,获取标识符,并找到相应的会话。
The browser (client) stores a session cookie containing a key-value pair. The key is usually JSESSIONID, and the value is a unique identifier. It is received by the client as a response of his request to the server, which initiates the session.
Whenever a request is made to the server, the browser sends that key-value pair in a special http header ("Cookie"). The server then reads that header, obtains the identifier, and finds the corresponding session.
你们为什么不先用谷歌搜索一下呢?
请参阅以下内容:
Why don't you guys use Google before asking?
See the following: