So there are a few things I know about this topic but I am having a hard time finding where or what to research for this application. I am developing a web app for c# and asp.net web forms and am saving information in session for each user.
I am just wondering when I should timeout session and any information about persisting session to a database so that it can be accessed later. The variables are being changed in session on a frequesnt basis and I do not want it to impact performance to persist these changes in the database each time.
The goal of this is to have variables saved in session for each customer’s information as they preform several transactions and pay at the end. If someone walks away for 10 mins and the session times out, I want a way to get that information back to complete the order. I also do not want this to affect performance.
I may also implement a session timeout that triggers a popup screen that will persist these changes to the database only if the user wishes and not each time something changes.
This is my first time dealing with session or caching in a web app and I would like to know more information or where to look or how you would attack this problem.
Thank you.
If the information you’re saving in the session is not sensitive, I suggest you store the information in cookies instead. Cookies won’t be affected by the session timeout. It also gives you the ability to use the data that you’ve persisted in another session at a later date.
For example: You could keep track of the items/products that the user views. Next time they visit, you could show them “Recently viewed items”. Amazon.com uses cookies for this purpose (and many, many others).
If you really want to store the information in the database OR the information is too much / too sensitive to store in a cookie, you could save it to the DB and then write a cookie with the ID of the record that contains the information. This way, when the user returns to the site, you could look up the previous sessions information in the DB based on the ID in the cookie.
ASP.NET Cookies Overview