I'm working on a web application using session variables. The sessions variables are stored in a db, so they can persist as long as I want them to. The variables store simple things as you might expect in a web application: last widget chosen, last report chosen, and stuff like that. They are all used so the user experience from page to page, and ajax call to ajax call, acts and feels like a typical desktop app.
Ok, nothing out of the ordinary so far. My question is, should I keep these settings around when the user comes back to the app a day or week later? Essentially, the app picks up where they left off (even though the underlying data will obviously change).
Or, should I just wipe out the session at the end of the users real session (ie. closes the browser)? And the next time they come to the app, they start fresh and everything is reset to the initial "home" page settings.
keeping session data around is always a sticky issue. Since you are storing the data in a db, I'll assume that your db is a proper client-server style db (sql server, oracle, mysql properly setup, or other db not called access). In addition, you will want to make sure that indexing is proper. I'd suggest a Date Entered type field populated by a trigger as well as an index on that field. That way, whatever you choose will allow for quick deletes.
Back to your question, I'd suggest 24 hours to start with along with a cleanup call that occurs at some semi regular interval. the trigger for the cleanup can be a session start or a session end. In ASP.NET/IIS, I'm not sure how reliable session end is, but i am not sure that it really has to be 100% reliable as you are just looking for cleanup to run sometime.
So from a usability point of view: If I come back in 24 hours, pickup where I left off. But if I come back a week later, start fresh?
(btw, not worried about the session mechanism and cleanup. using MySQL and PHP, combining session data with user data. i generally dont rely on any webserver session events. i'm kind of half rolling-my-own mechanism)