By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

how to check if user is inactive for some time

P: 22
hi friends,

I'm developing an application in which it is required that if user is inactive for 30 mins s/he should be logged out automatically...

i'm able to do it throught javascript by setting a timer and reducing the time
every second...but the problem here is i have to set the timer to max value every time an event is happening on any page...which i don't want...is there any solution for this problem??

it will be a great help for me if someone can provide me some solution for this..

Thanks in advance
Jan 15 '08 #1
Share this Question
Share on Google+
9 Replies


gits
Expert Mod 5K+
P: 5,333
hi ...

the javascript-value seems not very reliable for that purpose (could be tricked or simply avoided) ... you could use a serverside session and everytime a user takes an action compare the time and when it is more then 30min. then redirect him/her to the login-page and create a new session ... otherwise update the timestamp that is stored in the session

kind regards
Jan 15 '08 #2

P: 22
hi ...

the javascript-value seems not very reliable for that purpose (could be tricked or simply avoided) ... you could use a serverside session and everytime a user takes an action compare the time and when it is more then 30min. then redirect him/her to the login-page and create a new session ... otherwise update the timestamp that is stored in the session

kind regards
using server side validation is good but in my case lot of client side activities are there that user can work with without going to server...that's why i opted for javascript....

can you provide me some code snippet for this problem using server side session for validation...if javascript validation doesn't seems to be good then i'll use server side validation...

Thanks for the reply..
Jan 16 '08 #3

gits
Expert Mod 5K+
P: 5,333
hi ...

the clientside version doesn't need a timer too :) ... you could store a timstamp that you compare/update everytime you need it ...

for the serverside solution you should know which language you use and then ask for help/example in the appropriate forum ... (i guess you use PHP? ;) )

kind regards
Jan 16 '08 #4

P: 22
hi ...

the clientside version doesn't need a timer too :) ... you could store a timstamp that you compare/update everytime you need it ...

for the serverside solution you should know which language you use and then ask for help/example in the appropriate forum ... (i guess you use PHP? ;) )

kind regards
i'm also storing a timestamp and comparing it but this timestamp has to be reduced every second and if some activity is happening i have to reset that timestamp to original value..is this the right approach to work...i'm using c#.net and asp.net
Jan 16 '08 #5

gits
Expert Mod 5K+
P: 5,333
hmmm ... it depends on what you want to do ... you don't need the 'reduce-timer' in case you don't need an automatic redirect after the given time ... you simply could compare the timestamp with the current one and in case it is more the 30min then redirect the user ... otherwise (automatic redirect) you would need the timer ...

kind regards
Jan 16 '08 #6

P: 22
hmmm ... it depends on what you want to do ... you don't need the 'reduce-timer' in case you don't need an automatic redirect after the given time ... you simply could compare the timestamp with the current one and in case it is more the 30min then redirect the user ... otherwise (automatic redirect) you would need the timer ...

kind regards
my current approach is...i'm using a veriable with value 1800...i'm reducing it every second....if it reaches 0 i send a warning message to user for automatic logoff...if he says yes i redirect the page to login page again otherwise i reset the var to 1800....also if any activity happens i reset that variable to 1800..

is it what you are saying or its different...is it right in this way???

Regards
Jan 16 '08 #7

gits
Expert Mod 5K+
P: 5,333
yes ... for automatic redirect/logoff it would be the right way ...

but as i said: in case you would like to avoid the timer then you could redirect/logoff when the 'time-difference' of a user-action and a previous one is greater then 30 minutes ...

kind regards
Jan 16 '08 #8

P: 22
yes ... for automatic redirect/logoff it would be the right way ...

but as i said: in case you would like to avoid the timer then you could redirect/logoff when the 'time-difference' of a user-action and a previous one is greater then 30 minutes ...

kind regards
i think you are right...that will also be a good way of doing this....

Thanks for you suggestions...
Jan 16 '08 #9

gits
Expert Mod 5K+
P: 5,333
no problem ... in case you have more questions post back to the forum :)

kind regards
Jan 16 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.