Cookies and Session Basics:
Cookies are stored on the client, save a small amount of information, clear text, often used to save information such as user ID, the common scene is the login time "remember me." Saving sensitive information is not recommended.
Sessions are session-level, stored on the server side, each user is unique, can be used to implement the shopping cart and the like, need to save the current user session in the server context information requirements. Can be saved in the server's memory, not across the server, and can be saved in the database.
There are some scattered points of knowledge. In fact, there are many, such as cookies in the sessionid,session can also be saved with a state server, so you can save session with a dedicated server. The content in the cookie is a string type, and the content in the session is type object, and the contents of the session need to be converted to the desired type after the content is fetched.
In asp.net, you can configure it in the Web.config file.
<configuration>
<system.web>
<sessionstate mode= "InProc"
timeout= "
cookieless" = "true"
stateconnectionstring= "tcpip=localhost:42424"
sqlconnectionstring= "
/>
</ System.web>
</configuration>
Regarding the parameter information in the configuration section, you can view the storage of the ASP.net session state, speak more in detail, and find the article in detail cookies, and feel more detailed.
There are two problems.
1 After the client disables cookies, does session still work?
2 How cookies are delivered at the client and server side, the specific delivery process.
Reply.
1 After the client disables cookies, does session still work?
After you disable cookies, you can also use session.
The state of the session is stored in two places, the client and the server respectively. The client saves sessionid,session information on the server. The client's SessionID is stored in a cookie, and if the browser disables cookies, the benefit of the session cannot be used.
In fact, SessionID can also pass through the URL, can also be passed through form, can be customized to achieve.
In ASP.net, there are two ways to store sessions: cookies and cookieless. That is, disabling cookies can also use session. Once configured as Cookieless=true, you can optionally store sessions in the status service or in SQL Server. The specific approach can look at the final reference.
2 How cookies are delivered at the client and server side, the specific delivery process.
The delivery of cookies on both the client and server side is passed through the headers of the request and response.
Passing cookies from client to server is a cookie in the header of the request, which is the contents of the pass.
Passing cookies from the server side to the client is a Set-cookie in the header of the response, which is the contents of the cookie set through the background code.
This can be viewed through a lot of grab kits, such as Fiddler,httpwatch,firebug.
This article is from the "It architects in the breakout" blog, please be sure to keep this source http://virusswb.blog.51cto.com/115214/998456
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/