As in the title, I wonder how a session expires when the client’s browser is closed?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The session lives on the server. It expires when the browser is closed long enough or isn’t used long enough or when a new request arrives that either doesn’t contain the cookie, or the cookie refers to a sessionid that’s too far in the past (default timeout is 20 minutes).
When there’s no connection, the session is removed from memory at an undetermined moment in time, or when you programmatically call
.Abandonon the session.When a session is not available or a session has been cleared because it had timed out, a new session object will be created. When this is the result of a browser request, the
Session_Endevent will trigger in the global.asax file.Note: the actual way a session is timed out and cleared depends. I.e., inproc sessions will be destroyed and trigger a
Session_Timeout. Out-of-proc sessions do not, and will be destroyed in a state server or an SQL server. In the latter case, a stored procedure is called regularly to clean up. The stored procedure is only called when there’s activity on the server, which means that sessions can live longer than 20 minutes in (database) memory, but will be destroyed on next access.