上一篇介绍了cookie,这里来看看cookie与sessionID之间有什么关系。

一、编写测试用例代码

新建一个servlet如下:

public class SessionServlet extends HttpServlet {
private static final long serialVersionUID = 1L; /**
* @see HttpServlet#HttpServlet()
*/
public SessionServlet() {
super();
// TODO Auto-generated constructor stub
} /**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     System.out.println("----->进入doget方法......");
HttpSession session=request.getSession();
System.out.println("sessionId:---->"+session.getId()); //获得请求中的cookie
Cookie[] cs=request.getCookies();
if(cs!=null){//有cookie,并且又指定的cookie
System.out.println("cookie长度:"+cs.length);
for(Cookie co:cs){
System.out.println(co.getName()+";"+co.getValue());
}
}else{
System.out.println("没有cookie");
}
Cookie visitCookie=new Cookie("visitCookie","yes");
visitCookie.setMaxAge(60*60);//设置cookie失效时间
response.addCookie(visitCookie);
PrintWriter out=response.getWriter();
out.print("<html><body><h1>sessionId:"+session.getId()+"</h1></body></html>");
} /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
} }

二、开始测试

1.使用 火狐浏览器打开连接

第 1 次打开链接,请求头响应头如下:

【响应头】:

Connection close
Content-Language zh-CN
Content-Length 318
Content-Type text/html;charset=ISO-8859-1
Date Tue, 26 Feb 2019 03:11:49 GMT
Set-Cookie JSESSIONID=1D8268B571F492DDE6DA2A4D5B6BC2E3;path=/;HttpOnly

【请求头】

Accept text/html,application/xhtml+xm…plication/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Connection keep-alive
Host localhost:8899
Upgrade-Insecure-Requests 1
User-Agent Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/56.0

【控制台输出】:

sessionId : 1D8268B571F492DDE6DA2A4D5B6BC2E3

jsessionId:

第 2 次打开连接(刷新页面)

【响应头】

Content-Length 89
Content-Type text/html;charset=UTF-8
Date Tue, 26 Feb 2019 03:15:02 GMT

【请求头】

Accept text/html,application/xhtml+xm…plication/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Cache-Control max-age=0
Connection keep-alive
Cookie JSESSIONID=1D8268B571F492DDE6DA2A4D5B6BC2E3
Host localhost:8899
Upgrade-Insecure-Requests 1
User-Agent Mozilla/5.0 (Windows NT 10.0; …) Gecko/20100101 Firefox/56.0

【控制台输出】

sessionId: 1D8268B571F492DDE6DA2A4D5B6BC2E3

           jsessionId: 1D8268B571F492DDE6DA2A4D5B6BC2E3

第三次打开连接(再次刷新页面)

于第二次一致

结论:

首次访问时:服务器创建 session,并告诉客户端设置cookie来存储sessionId ,即如下响应头:

Set-Cookie JSESSIONID=1D8268B571F492DDE6DA2A4D5B6BC2E3;path=/;HttpOnly

再次访问时:客户端 携带此 存有此 sessionId (cookie中为jsessionId)的cookie给服务器。【告诉服务器,我就是刚才那个人】

2. 关闭浏览器看看 session 会如何变化

第一次访问,  响应头

Set-Cookie JSESSIONID=927B67009E1E4439F8857074B867AF3A;path=/;HttpOnly

sessionId : 927B67009E1E4439F8857074B867AF3A

jsessionId :

再次刷新:

sessionId: 927B67009E1E4439F8857074B867AF3A

jsessionId: 927B67009E1E4439F8857074B867AF3A

结论: 关闭浏览器之后,重新打开页面,会开启新的session

 3.禁用浏览器cookie,访问四次如下:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgsAAAEdCAIAAAANWrOCAAAgAElEQVR4nO2dwct0yVWHez35TzJZSoItZrKQgEIC4+abZRZj40YTyDKRBIkQI8M0giCGOC5EdJGNQivMLAyIEBhczEgYfCU4BBTdZEQRojDXRb/dXXXO75yqe/u+b3fffh6aj++9davqVNW59au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oUAgAANCgEAAAoEEhAABAg0IAAIAGhQAAAA0KAQAAGhQCAAA0KAQAAGhQCAAA0KAQAACgQSEAAECDQgAAgAaFAAAADQoBAAAaFAIAADQoBAAAaFAIAADQoBAAAKBBIQAAQINCAACA5v8BFLG0O1gQuxgAAAAASUVORK5CYII=" alt="" />

禁用cookie之后,每次sessionID都不一样

所以,当客户端禁用cookie之后,便不好跟踪用户了。这时可使用response.encodeURL

servlet中response.sendRedirect(response.encodeRedirectURL("2.jsp"));

jsp中:<a href="<%=response.encodeURL("http://localhost:6060/xxx/xxxServlet")%>">111</a>

 

cookie与sessionID之间的关系实验的更多相关文章

  1. cookie sessionStorage localStorage 之间的关系

    先说一个cookie 因为HTTP是无状态的 所以cookie诞生 用于保存会话信息 大小 4096b 一般在4095b以内 数量限制 20 -50 根据浏览器不同 操作的是一个字符串 可以设置参数 ...

  2. 实验12:Problem D: 判断两个圆之间的关系

    Home Web Board ProblemSet Standing Status Statistics   Problem D: 判断两个圆之间的关系 Problem D: 判断两个圆之间的关系 T ...

  3. [转] valuestack,stackContext,ActionContext.之间的关系

    三者之间的关系如下图所示: ActionContext  一次Action调用都会创建一个ActionContext  调用:ActionContext context = ActionContext ...

  4. PostgreSQL表空间、数据库、模式、表、用户/角色之间的关系

    看PostgreSQL9的官方文档,我越看越迷糊,这表空间,数据库,模式,表,用户,角色之间的关系怎么在PostgreSQL里这么混乱呢?经过中午的一个小实验,我逐渐理清了个中来龙去脉.下面我来还原我 ...

  5. PostgreSQL表空间、模式、表、用户/角色之间的关系

    PostgreSQL表空间.模式.表.用户/角色之间的关系是本文我们主要要介绍的内容,表空间,数据库,模式,表,用户,角色之间的关系到底是怎样的呢?接下来我们就开始介绍这一过程. 实验出角色与用户的关 ...

  6. valuestack,stackContext,ActionContext.之间的关系

    者之间的关系如下图所示: relation ActionContext 一次Action调用都会创建一个ActionContext 调用:ActionContext context = ActionC ...

  7. 泛型编程、STL的概念、STL模板思想及其六大组件的关系,以及泛型编程(GP)、STL、面向对象编程(OOP)、C++之间的关系

    2013-08-11 10:46:39 介绍STL模板的书,有两本比较经典: 一本是<Generic Programming and the STL>,中文翻译为<泛型编程与STL& ...

  8. VMware Workstation下VMnet1等虚拟网卡与主机网卡之间的关系

    VMware Workstation下VMnet1等虚拟网卡与主机网卡之间的关系 本文出自 "王春海的博客" http://wangchunhai.blog.51cto.com/2 ...

  9. LR的VG与Control之间的关系,并发的实质

    LR的VG与Control之间的关系,经过无数次的实验,搞清楚了现实意义的并发.传说每秒有几百,几千,几万用户并发,基本属于设想状态. 在一秒内处理多少个请求,完全在于服务器处理能力的强弱.这里需要强 ...

随机推荐

  1. ubuntu 16.04 安装 QQ

    需要在Ubuntu 16.04下使用QQ,查找了一下,知乎的办法可行. 参考了:http://www.zhihu.com/question/20176925 与 http://www.zhihu.co ...

  2. ZOJ-2365 Strong Defence 无公共边割边集

    题意:该题的题意晦涩,勉勉强强听别人说了一遍后再读了一遍题才算懂了题意,题图说的是A国因为B国药进攻自己的国家,于是想办法在联通A-B之间的路径上进行阻击.阻击的舰船停留在一个路径上,舰船上都要放置水 ...

  3. effect c++ 口诀。

    常用条款,写成口诀,记住.知其所以,也要时时使用. 1)习惯c++: 联替const初. 2)构造,复制,析构: 要知默,构赋析. 若不需,明拒绝. 构析不调虚. 异不逃析构. 基析要虚函. 赋值操, ...

  4. SAP屠夫---折旧在13-16调整期间的烦恼(转)

    "应尽量避免在13-16期的折旧行为",在去年新准则ERP调整时就强调过,实际上, 有的企业并不使用13-16期间, 假设某家企业将折旧折在13期, 非常可惜的是,sap的折旧费用 ...

  5. CentOS6下yum下载的包存放路径

    http://showerlee.blog.51cto.com/2047005/1169818 yum下载下来的文件保存默认路径是: /var/cache/yum 修改yum配置文件 /etc/yum ...

  6. jquery.pagination.js分页

    参数说明 参数名 描述 参数值 maxentries 总条目数                           必选参数,整数 items_per_page 每页显示的条目数            ...

  7. Python学习(14)模块一

    目录 Python 模块 import语句 from ... import 语句 from ... import * 语句 定位模块 PYTHONPATH变量 命名空间和变量 dir()函数. glo ...

  8. Java将其他数据格式转换成json字符串格式

    package com.wangbo.util; import java.beans.IntrospectionException; import java.beans.Introspector; i ...

  9. Oracle分析函数的项目实践实例

    SELECT * FROM SSE2_FLOW_EXPENSE T1 JOIN (SELECT SFEL.*, ROW_NUMBER() OVER(PARATITION BY SFEL.FE_EXPE ...

  10. 关于json 的那些知识点

    深入理解JSON对象 前面的话 json(javascript object notation)全称是javascript对象表示法,它是一种数据交换的文本格式,而不是一种编程语言,用于读取结构化数据 ...