1. ["username"] = null
HttpSessionState internally uses a collection object of type NameObjectCollection to store user data. Therefore, using ["username"]= null is just to set the value of the element to null, and it is not really removed from the Session. (Why? Dizzy~~~ It is recommended to read the basics of C#.)
The correct way is: ("username");
Delete all data: (); or ();
2. ()
This method will cause the current Session to be cancelled, and the system will trigger the Session_End event in (only when Mode = InProc ).
Although the SessionID (probably) did not change when the request is made again, you will find that the Session_Start event is triggered. You can also use the attribute to determine whether the current Session was recreated.
Since some components and controls may need to use Session information (such as synchronizing with ), do not use this method to clean up Session easily.
3. User ID authentication
Do not use ["username"] = "ZhangSan" , if (["username"] != null) to perform user authentication. This method is neither safe nor reasonable. For identity verification, please refer to the MSDN document or related articles written by Yuhen.
HttpSessionState internally uses a collection object of type NameObjectCollection to store user data. Therefore, using ["username"]= null is just to set the value of the element to null, and it is not really removed from the Session. (Why? Dizzy~~~ It is recommended to read the basics of C#.)
The correct way is: ("username");
Delete all data: (); or ();
2. ()
This method will cause the current Session to be cancelled, and the system will trigger the Session_End event in (only when Mode = InProc ).
Although the SessionID (probably) did not change when the request is made again, you will find that the Session_Start event is triggered. You can also use the attribute to determine whether the current Session was recreated.
Since some components and controls may need to use Session information (such as synchronizing with ), do not use this method to clean up Session easily.
3. User ID authentication
Do not use ["username"] = "ZhangSan" , if (["username"] != null) to perform user authentication. This method is neither safe nor reasonable. For identity verification, please refer to the MSDN document or related articles written by Yuhen.