1

Hi all, I have gone through this example to end session when user was inactive for some amount of time which works fine

http://www.philpalmieri.com/js_sandbox/timedLogout/

But when it redirects back to logout page and if I access the page with sessions I am able to see the page access with the data. I don't want this to be done. When user logged out on inactive session through the jQuery function I would like to kill the session which I am having too? How can I achieve this?

1 Answer 1

2

You may use logout_url option for that purpose. Create generic http handler in your project and use it for performing logout on server:

Hahdler's code:

public class LogoutHandler : IHttpHandler, IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Session.Abandon();
        FormsAuthentication.SignOut();
    }

    public bool IsReusable
    {
        get
        {
            return true;
        }
    }
}

markup:

$(function () {
     $(document).idleTimeout({
          inactivity: 30000,
          noconfirm: 10000,
          sessionAlive: 10000,
          logout_url: '<%= ResolveClientUrl("~/LogoutHandler.ashx") %>',
          redirect_url: '<%= ResolveClientUrl("~/LogoutHandler.ashx") %>' // suggested by Ramakrishna
     });
});
Sign up to request clarification or add additional context in comments.

11 Comments

Should i call this process request in my application?
@Ramakrishna no, you shouldn't
But this didn't work for me.. I just wrote as per you said but in the script i called as follows logout_url: 'LogoutHandler.ashx', is it ok or should i call as per you written
Even though i wrote as per you given it didn't work for me.. Still i am able to view the page
You may write 'LogoutHandler.ashx' till handler located at the same level as you page where you use idleTimeout. I'm forgot that for access to Session your handler must be marked with IRequiresSessionState interface. Check updated answer
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.