- session:
Is to keep track of each user's request. So each time the web page is posted back asp.net runtime knows from which user the request is coming from. Now since HTTP is a stateless protocol, meaning each request from the same user is like a new request to it. So, to maintain a session Asp.Net has Session variables.
Session Variables:
The session variables are variables maintained on server side by asp.net runtime. Each user is identified by a a unique number called SessioID. This session is stored in a cookie (if browser supports cookie) on client side after the first user request. when the client posts back a page , this cookie is available in the request header. So now server knows that this user request is coming from which user. Besides this you can also store user specific information in session variables, which will be availale on server side.
HTTP是一种无状态的连接,为了将多次HTTP连接关联起来,就有了Cookie和Session机制,它们用来记录HTTP状态,跟踪会话。不过Cookie存在于客户端,且大小相当有限,而Session存在于服务器端。
网友评论