I used cookies to save the user ID when I log on to the system. However, there was a small problem when I exited.
Code
Response. Cookies. Clear ()
However, when you exit, you still cannot exit. Cookies are still present! I was puzzled at the beginning.CodeThe prompt in is to clear all cookies in the set, but why is it still there? I checked the information and said that it was necessary to set the expiration time. I changed the code again.
Code
Foreach (Httpcookie cookie In Response. Cookies)
{
Cookie. Expires = Datetime. Today. adddays ( - 5 );
Response. Cookies. Remove (cookie );
}
After the modification, the cookies are still in progress. last found for half a day, originally response. cookies. clear () only clears cookies that are now added to response. client Cookies cannot be cleared. after changing the code, you can finally
Code
Foreach ( String Cookiename In Request. Cookies. allkeys)
{
Httpcookie = Request. Cookies [cookiename];
Cookie. Expires = Datetime. Today. adddays ( - 5 );
Response. Cookies. Add (cookie );
}
This problem may not be noticed during normal use!