| Home » Categories » Multiple Categories |
Issue with Storing Session |
|
Article Number: 301 | Rating: Unrated | Last Updated: Wed, Sep 24, 2025 at 12:08 AM
|
Sometimes, the session on your website can expire earlier than you expect. The followings are the steps you need to check:
1. In .Net, you cannot use authentication without session. The session ID can be transmitted with client either in a cookie, or in the page url. There is no need to choose between session and cookie, as the cookie actually holds the session id.
2. On the server, session data is stored either in memory (in process or outside process), or in database.
3. The cookie is encrypted using a key called the "machine key". By default, everytime the app pool is recycled, a new machine key is created and the session data that is in memory is lost. On a shared server, this results in the end of a session, since the cookie cannot be decrypted anymore.
The solution: Store a static machine key in the web.config of the web application.
Also, storing the session data in the database instead of memory (in proc) can be useful to preserve sessions.
|
Attachments
There are no attachments for this article.
|
How to Solve the error: "405 - HTTP verb used to access this page is not allowed"?
Viewed 5527 times since Wed, Oct 24, 2018
Sample Code to Send email using ASP.NET 2
Viewed 9895 times since Tue, May 1, 2012
How can I enable ASP.NET 3.5 on your Control Panel?
Viewed 4032 times since Wed, May 2, 2012
How to Solve an Error Message "Validation of viewstate MAC failed"
Viewed 9655 times since Tue, Apr 2, 2013
HTTP Error 502.5 - Process Failure error message when publishing an ASP.NET Core Website
Viewed 11007 times since Mon, Mar 27, 2017
I get an error Server.CreateObject Failed when I try to use CDONTs. What can I do?
Viewed 3104 times since Tue, May 1, 2012
How to solve the Let’s Encrypt SSL on ASP.NET Core
Viewed 9777 times since Mon, Jul 17, 2017
How do I query MySQL Database in PHP ?
Viewed 3565 times since Tue, May 1, 2012
I cannot find a way to enable ASP.NET 4.5 on my Control Panel
Viewed 11179 times since Tue, Sep 11, 2012
How do I send an email from my ASP.NET website by using SMTP Authentication?
Viewed 6715 times since Tue, May 1, 2012
|
