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 );
}