Session and cookie in ASP. NET

Source: Internet
Author: User
SessionidProperty uniquely identifies a browser that contains session data on the server. SessionidValues are randomly generated by ASP. NET and stored in non-expired cookies of the browser. Apply to ASP. NET each time ProgramWhen sending a request, SessionidThe value is sent to the cookie.

SessionidSend the cookie or URL between the server and the browser in plain text format. In this case, it is not necessaryCodeMay obtainSessionidValue is included in the request sent to the server, so that the user can access the session of another user. If you need to store private or sensitive information in the session state, we recommend that you use SSLSessionidAny communication between servers is encrypted.

When session status based on cookies is used, ASP. NET can allocate session data storage only after session objects are used. Therefore, a new session ID is generated for each page request before accessing the session object. If your application requires a static session ID for the entire session, you can implementSession_startMethod, and store the data inSessionTo fix session IDs, or you can use code to explicitly store data in other parts of the applicationSessionObject.

If your application uses the cookieless session status, the session ID is generated on the first page view and maintained throughout the session.

Read sessionid:
Protected void page_load (Object sender, eventargs E)
{
Response. Write (this. session. sessionid );
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.