Search code examples
asp.netmobile-websitemobile-phones

how do we create a new session on the page if it has timed out


is there a way to create a new session if it has timed out ? in mobile appication developing using asp.net?

getting this error:

the page requires session state that is no longer available. either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. try increasing the history size or session expiry limit

this is what i have in my web.config:

  <sessionState cookieless="UseCookies" cookieName="Mobile_Session" regenerateExpiredSessionId="true">
    </sessionState>

Solution

  • Session handling is done on the server so if the client sends a request after their current session has timed out the the ASP.Net application will automatically create a new session.

    As far as I know once the session has timed out it is not possible to restart it or recover information from it. If you want to prevent a session from ending then you could send a small AJAX request periodically to prevent it (e.g. if you session ends after 20 minutes then send a request every 15 minutes). This request would force the session to stay active.