Reputation: 5315
if anyhow my session have ended then how can i start the session again in the code.
Upvotes: 1
Views: 85
Reputation: 2795
Traditionally, if you wanted a session to stay alive, you had to write your app in such a way that requests were continually made to the server within the session timeout. This could be using a ajax request or a iframe postback on a javascript timer. I never really liked those methods, but for some apps they made sense.
Here is a simple example of a ajax-based session-refresh: http://naspinski.net/post/Automatically-refresh-your-users-Session-behind-the-scenes-using-jQuery-and-AspNet.aspx
Upvotes: 0
Reputation: 700402
You can't. When the session is gone either from the browser or the server, it can't be reopened, you have to start a new session.
Reopening a session that was closed in the browser would be a potential security risk. Reopening a session that was closed from the server isn't possible as the data simply doesn't exist any more.
Every request is done in the scope of a session (unless you specifically make a session-less request), so if the session is closed for any reason, a new one is automatically created at the next request.
Upvotes: 1