I have developed an asp.net app that uses forms authentication with a custom membership module. The app's users fall into several categories, some of which require that the user be restricted from using the app at certain times of the day. I am able to prevent
users from logging in during these restricted times, however, in an ideal world, they shouldn't be able to use the app at all during these times, so if they log in prior to the restricted time, I would like to be able to force a logout. Has anyone ever created
this functionality before? Ideally, it would be nice to be able to display some sort of message informing them that their time window of use is nearing an end and that they should save any work they have. I imagine this could be done through AJAX. But first
things first.. is there smoe way to force individual users to log out in a forms authentication scenario?
You may user jQuery timer to display time remaining in the session. You may also have a pop-up displayed 5 minutes before the actual time out to ask users to save their work.
http://keith-wood.name/countdown.html
http://plugins.jquery.com/project/timers
When time is up you could do a AJAX post to force a log out.
Has anyone ever created this functionality before?
I have never seen such application. But, it is not impossible either. When one checks for a certain Role and restricts access over one page, then in the Page_Load event handler it can be checked certain time also forcing Logout.
akashenk
Member
436 Points
218 Posts
forced logout
Nov 16, 2010 12:32 PM|LINK
I have developed an asp.net app that uses forms authentication with a custom membership module. The app's users fall into several categories, some of which require that the user be restricted from using the app at certain times of the day. I am able to prevent users from logging in during these restricted times, however, in an ideal world, they shouldn't be able to use the app at all during these times, so if they log in prior to the restricted time, I would like to be able to force a logout. Has anyone ever created this functionality before? Ideally, it would be nice to be able to display some sort of message informing them that their time window of use is nearing an end and that they should save any work they have. I imagine this could be done through AJAX. But first things first.. is there smoe way to force individual users to log out in a forms authentication scenario?
sachingusain
Star
8786 Points
1702 Posts
Re: forced logout
Nov 16, 2010 01:25 PM|LINK
You may user jQuery timer to display time remaining in the session. You may also have a pop-up displayed 5 minutes before the actual time out to ask users to save their work.
http://keith-wood.name/countdown.html
http://plugins.jquery.com/project/timers
When time is up you could do a AJAX post to force a log out.
You may do something like this:
function LogMeOut() { $.ajax ( { type: "POST", url: "http://localhost:11151/default.aspx/Logout", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert(msg.d); } } ) } setTimeout(LogMeOut, 1000);You may also look at this:
http://philpalmieri.com/2009/09/jquery-session-auto-timeout-with-prompt/
Thanks.
sanjibsinha
Contributor
5014 Points
947 Posts
Re: forced logout
Nov 16, 2010 02:24 PM|LINK
I have never seen such application. But, it is not impossible either. When one checks for a certain Role and restricts access over one page, then in the Page_Load event handler it can be checked certain time also forcing Logout.
forced logout
12reach: asp.net meets php
akashenk
Member
436 Points
218 Posts
Re: forced logout
Nov 16, 2010 08:45 PM|LINK
That's exaclty what I was looking for, and the countdown appears to be a very handy utility. THanks for the help!