In a module I wrote I store in the session the items the user added to his cart.
How would you handle this situation: The user adds a new item to his cart after the session timedout?
I can redirect to the homepage but then I’m causing the redirect to happen even when the session wasn’t in use. like when the user isn’t logged in, or his cart was empty.
How do you handle session timeout in your applications?
In this case, I might not use the built in ASP.NET Session provider. Instead you could set a persistent cookie for the customer’s shopping cart session with an encrypted ID that maps to a session stored in the database, which stores the contents of the cart.
This way, you don’t need to worry about timeouts, the session will continue for the lifetime of the cookie.
(If you really need to use ASP.NET Session, maybe you’ve already got code that uses it, then you could set the timeout to a very large number and configure the Session state provider to use SQL Server.)