关于SessionID
1、客服端首次访问时,服务器端创建Session对象,生成SessionID。
2、SessionID会被发送到客户端,保存在浏览器内存中。
3、对于IIS, 如果不使用Session,SessionID不发送给客户端,测试如下:
不使用Session:
2012-02-09 12:38:08,049 - INFO - requestfile - Sessionid:xcp5ov55khxply45a0k1ok3v
2012-02-09 12:38:12,386 - INFO - requestfile - Sessionid:nnb1s555jmaajp45o5hlle45
2012-02-09 12:38:15,989 - INFO - requestfile - Sessionid:yfjamb452uv4ruyvfo5hjo45
2012-02-09 12:38:12,386 - INFO - requestfile - Sessionid:nnb1s555jmaajp45o5hlle45
2012-02-09 12:38:15,989 - INFO - requestfile - Sessionid:yfjamb452uv4ruyvfo5hjo45
使用Session后:(Session["test"] = "test";)
(1)不关闭浏览器,多次请求SessionID不变 。
2012-02-09 12:45:23,996 - INFO - requestfile - Sessionid:rhu54ba5trnvjh55lkhu5z45
2012-02-09 12:45:25,774 - INFO - requestfile - Sessionid:rhu54ba5trnvjh55lkhu5z45
2012-02-09 12:45:34,479 - INFO - requestfile - Sessionid:rhu54ba5trnvjh55lkhu5z45
2012-02-09 12:45:25,774 - INFO - requestfile - Sessionid:rhu54ba5trnvjh55lkhu5z45
2012-02-09 12:45:34,479 - INFO - requestfile - Sessionid:rhu54ba5trnvjh55lkhu5z45
(2) 关闭浏览器,SessionID变化。
2012-02-09 12:47:24,549 - INFO - requestfile - Sessionid:xbwcp3ukc3upekzujhgkauup
2012-02-09 12:47:25,891 - INFO - requestfile - Sessionid:xbwcp3ukc3upekzujhgkauup
2012-02-09 12:47:25,891 - INFO - requestfile - Sessionid:xbwcp3ukc3upekzujhgkauup
4、禁用Cookie,SessionID不能被保存在浏览器内存中。
(1)多次请求同一页面,SessionID变化。
2012-02-09 13:09:54,741 - INFO Sessionid:ln13eo55kf3if5mts2ppff55
2012-02-09 13:09:55,459 - INFO Sessionid:hxyt5d55lcrqjb45xrwlwe45
2012-02-09 13:09:56,192 - INFO Sessionid:yv52cn45d223ot45y4d4qx45
(2)启用Cookie后,SessionID不再变化。2012-02-09 13:09:55,459 - INFO Sessionid:hxyt5d55lcrqjb45xrwlwe45
2012-02-09 13:09:56,192 - INFO Sessionid:yv52cn45d223ot45y4d4qx45
2012-02-09 13:10:15,754 - INFO - requestfile - Sessionid:t25myzaqikyi0f455nj44l45
2012-02-09 13:10:17,330 - INFO - requestfile - Sessionid:t25myzaqikyi0f455nj44l45
2012-02-09 13:10:17,330 - INFO - requestfile - Sessionid:t25myzaqikyi0f455nj44l45
以上测试假设Session对象在销毁期间内。
作者:青羽