Last post Feb 06, 2012 02:05 AM by Dino He - MSFT
Feb 03, 2012 05:27 PM|ahmedilyas|LINK
What is the real benefit for me using SQL Server to store user session? (apart from the whole thing about having a webfarm and no guarentee which server will be executing the request and storing it in SQL means centralized storage)
Secondly, how do I implement ASP.NET Session for SQL? How would one write the code to retrieve an item from session where SQL is concerned?
What I am looking for is a solution to help me where for example, I have a site where users can log in and "shop".
I would store the user object in session, but when the session expires, it means the user needs to log in again. I want the case where if the session expires, to automatically load the session again for the user so it is persisted and no need to relogin
How can I implement this?
Feb 03, 2012 05:43 PM|sivakumar321|LINK
One way you can increase session Timeout.
Feb 03, 2012 05:46 PM|ahmedilyas|LINK
yes I know that.
however doesnt help with the original question really :-)
Feb 04, 2012 12:11 AM|JSavvy|LINK
It is mainly for spanning web farms and surving reboots of front end servers.
For example, if you are running the state service vs sql and you need to reboot the server running state service, you loose your sessions on the reboot. The sql path will give you additional persistance in the database vs in memory of the state service
and of course inproc.
There is overhead in the sql model that you don't have in the inproc or state service model, but it's strength is that it's not in memory and can survive reboots.
In your case, you want the session to last longer. Once a session expires, there is no re-loading the expired session. In short you can't implement this. If you want to persist data longer than the session, just write it to the database and associate
with userid - not the session.
Feb 04, 2012 04:26 AM|ahmedilyas|LINK
I just need to make sure that when the session expires, it can redirect to a user logon page.
Feb 06, 2012 02:05 AM|Dino He - MSFT|LINK
You can use cookie and seesion together.
If some one are shoping store the message in cookie.
Once he want to pay the money, he need to have the message in session.
That's a good solution.