Home » Categories » Multiple Categories

Issue with Storing Session

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 Attachments
There are no attachments for this article.
Related Articles RSS Feed
My website session times out earlier than expected. Why?
Viewed 4178 times since Tue, May 1, 2012
How to solve the Let’s Encrypt SSL on ASP.NET Core
Viewed 8367 times since Mon, Jul 17, 2017
I receive this error message: "Directory Listing Denied. This Virtual Directory does not allow contents to be listed."
Viewed 9767 times since Mon, Apr 30, 2012
How do I redirect a subdomain to a subdirectory?
Viewed 3246 times since Tue, May 1, 2012
Do you allow custom COM components?
Viewed 2136 times since Tue, May 1, 2012
About Azure Key Vault
Viewed 564 times since Mon, Nov 2, 2020
I get an error Server.CreateObject Failed when I try to use CDONTs. What can I do?
Viewed 2150 times since Tue, May 1, 2012
I cannot see my website. What should I do?
Viewed 2833 times since Thu, May 3, 2012