Change the value of ASP. net_sessionid

Source: Internet
Author: User

You can change the value of ASP. net_sessionid to obtain the stored session value of ASP. net_sessionid.

1) Because Session Initialization is performed on the acquirerequeststate event, you must modify the value of ASP. net_sessionid before calling the acquirerequeststate event.

2) After modifying the value of ASP. net_sessionid, you must return the modified value to the client to modify the cookie value of the client.

1. The value of ASP. net_sessionid must comply with its rules. Otherwise, the system will generate a new one by default. If the modified ASP. net_sessionid is in another domain, the system generates a new

ASP. net_sessionid value, which is assigned to ASP. net_sessionid under this domain, without generating a new ASP. net_sessionid under its corresponding domain.

2. Of course, the first point mentioned above is to modify the response value before the system assigns the response value. If you modify the value of response after it is assigned to the system, it will not be affected.

 

Sessionid Generation Process

First, sessionid is generated in sessionstatemodule, which is generated in the acquirerequeststate event. The call method is as follows:

 

Internal bool createsessionid ()
{
Bool flag;
This. _ rqid = This. _ idmanager. createsessionid (this. _ rqcontext );
This. _ idmanager. savesessionid (this. _ rqcontext, this. _ rqid, out flag, out this. _ rqaddedcookie );
Return flag;
}

As shown in the preceding figure, this. _ rqid is the generated sessionid. The createsessionid method of the instance of sessionidmanger is called. The call method is as follows:

 

Public Virtual string createsessionid (httpcontext context)
{
Return sessionid. Create (ref this. _ randgen );
}

From aboveCodeWe can see that it calls the static method create of the seesionid class and the parameter is of the ref type. Therefore, through consideration, the validity period of sessionid is the life cycle of the sessionidmanger instance. The method is as follows:

Internal static string create (ref randomnumbergenerator randgen)
{
If (randgen = NULL)
{
Randgen = new rngcryptoserviceprovider ();
}
Byte [] DATA = new byte [15];
Randgen. getbytes (data );
Return encode (data );
}

 

 

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.