无论如何,我主要关心的是使用 Session。我一直有这样的印象:如果您使用以下语句(我不会):
Session["newVar1"] = "a new session variable";
Session["newVar2"] = "a new session variable";
Session["newVar3"] = aLargeVariableThatHoldsLotsOfData;
您将创建 3 个具有特定值的新会话 cookie。但我认为我的 asp 书 表明您实际上会在会话状态对象中创建 3 个新变量,并且 ASP 只会传递唯一的会话 ID(作为 cookie?)在响应中,并会在下一个请求时获取此 ID,并将该 ID 与您的会话状态对象(IIS 已存储在内存中......?)相关联:
...它创建一个会话状态对象
包含一个唯一的会话 ID
每个用户的会话。这个ID已通过
返回到浏览器作为
响应,然后返回到
服务器处理下一个请求。网络平台
然后可以使用会话 ID 来获取
关联的会话状态对象
与请求。
对于流量很大的网站来说,这似乎并不理想。每个网站存储和维护成千上万个会话状态实例的服务器似乎过载太多。
我试图自己查看发生了什么,但我遇到了麻烦..我无法在我的计算机(IE/Windows XP)上的任何位置找到我的网站的 Cookie。我检查了 C:\Documents and Settings\nicholasr\Cookies\
和 C:\Documents and Settings\nicholasr\Local Settings\Temporary Internet Files
,根据 < a href="http://uk.answers.yahoo.com/question/index?qid=20070206061307AA6dSD6" rel="nofollow">此 yahoo 答案,也会存储 IE cookie。我在我的应用程序中使用票证身份验证,该应用程序在客户端上存储身份验证 cookie,因此我网站上的 cookie 必须位于某处..
我想我在问:
1)如果有人可以帮助我了解会话状态在幕后如何工作
2) IE 在哪里存储我网站的 cookie? ><
Anyway, my main concern is using Session. I've always been under the impression that if you use the following statements (not that I would):
Session["newVar1"] = "a new session variable";
Session["newVar2"] = "a new session variable";
Session["newVar3"] = aLargeVariableThatHoldsLotsOfData;
You would be creating 3 new session cookies that hold the particular value. But I think my asp book is indicating that you would actually create 3 new variables in your session state object and ASP would only pass a unique Session ID (as a cookie?) in the response, and would get this ID upon the next request and associate that ID with your Session State Object (that IIS has stored in memory..?):
...it creates a session state object
that contains a unique session ID for
each user's session. This ID is passed
back to the browser as part of the
response and then returned to the
server with the next request. ASP.NET
can then use the session ID to get the
session state object that's associated
with the request.
That doesn't seem ideal for a website with lots of traffic. A server that is storing and maintaining thousands and thousands of instances of session state per website seems like way too much overload.
I'm trying to see what's going on on my own, but I'm having trouble.. I can't find my site's cookies anywhere on my machine (IE/windows xp). I've checked C:\Documents and Settings\nicholasr\Cookies\
and C:\Documents and Settings\nicholasr\Local Settings\Temporary Internet Files
which, according to this yahoo answer, IE cookies are stored as well. I'm using ticket authentication in my app which stores a auth cookie on the client, so a cookie from my site has to be somewhere..
I guess I'm asking:
1) If someone can help me understand how Session State works behind the scenes
2) Where is IE storing my site's cookies? ><
发布评论
评论(1)
有一个代表 GUID 的会话 cookie。会话值本身存储在服务器上。因此,当您编写:
一个可能看起来像这样的 HTTP cookie 被发送到客户端。该 cookie 仅包含一个 id,而不包含实际值。实际值可以存储在服务器内存、单独的进程甚至 SQL Server 中,具体取决于
。然后,当稍后客户端发送另一个请求时,它将将此 cookie id 发送到服务器,并根据给定的 id,服务器将获取实际值。
客户端浏览器将这些 cookie 存储在内存中,这意味着如果您关闭它,会话将会丢失,因为会话 cookie 不是持久性的。
There is a single session cookie which represents a GUID. The session values itself are stored on the server. So when you write:
an HTTP cookie that might look like this is sent to the client. This cookie contains only an id, not the actual values. The actual values could be stored either in the server memory, a separate process, or even SQL Server depending on the
<sessionState mode=""
in web.config. Then when later the client sends another request it will send this cookie id to the server and given id the server will fetch the actual values.The client browser stores those cookies in memory, meaning that if you close it, the session will be lost because session cookies are not persistent.