loveprogramming
loveprogramming

Reputation: 578

(asp.net) Preserving some session variable in SQL Server after session time out possible?

I am new to asp.net. So please help me out. I am trying to preserve some session variable by changing the session mode to SQLServer using instruction on this link:

http://blogs.msdn.com/b/akshayns/archive/2008/10/04/how-to-configure-sql-server-to-store-a-session-state.aspx

I have read some posts saying that storing session in SQL Server database will preserve the session even after session time out. But in my case, after session time out, the session in aspstateTempSessions table is deleted as well. Is there a way I can tell asp.net to keep some session variables that I want to preserve after time out?

Thanks.

Upvotes: 0

Views: 569

Answers (1)

mgnoonan
mgnoonan

Reputation: 7200

Session is a volatile storage system, designed to only live as long as the session is active. If you need values to survive the session, you should go ahead and store them in a separate persistent structure, such as a SQL table that is tied to the user (not the session).

Edit: If you can come up with an object structure to store the "state" of the wizard (steps completed, options selected, etc.), you could serialize the objects and store them as an XML BLOB in SQL Server, with the user's login and ProductID as the primary keys. That way you can deserialize the state and the user can resume from where they left off.

As I stated in the comments, you'll want to setup an abandonment timeout period, after which all edits for that object are deleted and considered lost.

Upvotes: 3

Related Questions