Reputation: 203
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?
Upvotes: 1
Views: 3307
Reputation: 22478
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
});
});
Upvotes: 2