When the users login on my asp.net website (through FormsAuthentication), I store some information about them in the current session such as their UserId, FirstName and other very basic variables that I need frequently in various web pages.
The problem is that even if the session timeout is set to be longer than the FormsAuthentication timeout, I've noticed that sometimes the current session is reset (ie session=null).
1) I don't understand why it happens. Any ideas?
2) When this happens, the users are still logged in (FormsAuthentication has not timed out yet) but their current session doesn't contain any data anymore. What I would like to do is that when the current session times out, they're asked to login again. To do so, I would need to detect the session timeout and, when it occurs, log them out. How can this be done?
3)This seems a bit overkill. Can't I simply store whatever I store in the session (UserId, FirstName,etc) directly in FormsAuthentication? if so, how? This way I will have access to those values while they're still logged in regardless of the current session (which will not be used anymore in this case). Do you see anything wrong with this logic? If not, how can this be done?