Chrome开发者工具Network标签页中观察到的set-cookie jsessionid是什么东西
在Chrome開發(fā)者工具里經常能觀察到HTTP響應里包含的字段:
Set-Cookie: JSESSIONID= XXX
之后,就能在客戶端cookie里觀察到JSESSIONID=后面的值。
根據Google搜索的結果:
https://javarevisited.blogspot.com/2012/08/what-is-jsessionid-in-j2ee-web.html
這篇博客有詳細介紹:
What is JSESSIONID in JSP-Servlet
JSESSIONID是由Servlet容器比如Tomcat或Jetty等生成的,用于基于HTTP協(xié)議的J2EE web應用中進行session管理。
因為HTTP是一種無狀態(tài)的協(xié)議,Web服務器無法區(qū)分來自同一個客戶端的兩個不同請求,因此需要Session管理機制,具體實現有Cookie和URL Rewriting等。
JSESSIONID is a cookie generated by Servlet containers like Tomcat or Jetty and used for session management in J2EE web application for HTTP protocol. Since HTTP is a stateless protocol there is no way for Web Server to relate two separate requests coming from the same client and Session management is the process to track user session using different session management techniques like Cookies and URL Rewriting.
采用Cookie會話管理的服務器會在客戶端第一次請求時生成JSESSIONID,然后返回給客戶端。客戶端隨后每次請求都會把這個JSESSIONID附在HTTP請求頭部。
比如我們下面這個例子,是不是看到了前面出現在HTTP response set-cookie字段里的JSESSIONID值,在第二個接下來的請求里出現在HTTP request field上了?
If a Web server is using a cookie for session management it creates and sends JSESSIONID cookie to the client and then the client sends it back to the server in subsequent HTTP requests. JSESSIONID and session management is a not only a popular Servlet interview question but also appear in various JSP interviews. Along with What is JSESSIONID interviewer are also interested in when and howJSESSIONID is created in Servlet and JSP which we will see in next section.
如果客戶端瀏覽器禁掉了cookie,那么服務器仍然可以生成JSESSIONID,只不過以URL重寫的技術,把這個JSESSIONID值傳回客戶端:
https://localhost:8443/supermart/login.htm;jsessionid=1A530637289A03B07199A44E8D531427
要獲取更多Jerry的原創(chuàng)文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的Chrome开发者工具Network标签页中观察到的set-cookie jsessionid是什么东西的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gta5珠宝店位置在哪
- 下一篇: 利用微信登录掘金网站的HTTP请求分析