Controling time of user inaction

fomalhaut

Member
Messages
107
Reaction score
0
Points
16
Hello.

On my page (written with php, mysql, html) after a user has connected himself (giving user name and password), the menu is changed, according to his "hierarchical level".

I want to be sure he doesn't stay connected without action over a certain delay.

How can I do that ? Does a javascript function controled by timeout(xx,nn) can be a good way for that, or are there better ways ?

Thanks.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
One way would be to store the "last time logged in acted" along with the session info.

Each time he accesses a page, check the time.

If it has been too long, log him off and redirect to log-in page (store the URL he wanted in session info so you can send him there after he successfully logs back in).

If he is OK, update the timestamp and give him the page.

You can also "kick him off the page", ie set window.location= "loginpage.php" by using a timeout created in a window.onload handler.
 
Last edited:

fomalhaut

Member
Messages
107
Reaction score
0
Points
16
Thank you, Descalzo for your help.

I presume it is possible to test any event, such as mouse click, or key down, anywhere on the page, probably in the "body" section, not only access to new page ?

I'll try that.

Thanks again. ;)
 

drf1229

New Member
Messages
71
Reaction score
1
Points
0
If you are using cookies for your login sessions you can set the expiration time of each cookie.
 
Top