xyn Posted September 24, 2006 Share Posted September 24, 2006 Hey guys,Just have a short, quick querstion. I have a admin control unitand I wanted to add a 5 minute inactivity, everytime the pageis refreshed (uses another page within the acp) The time stampis updatedYet if the admin leaves their accoutn for over 5 minutes whenthey refresh the page it checks the Current time with the timestampand it tells them they're not logged in?My clock formatt is... H:i:s, (00:00:00) could someone give me a smallpointer on how to fix this.Thanks! Quote Link to comment Share on other sites More sharing options...
Barand Posted September 24, 2006 Share Posted September 24, 2006 How to fix what ? Clock format? Quote Link to comment Share on other sites More sharing options...
WendyLady Posted September 24, 2006 Share Posted September 24, 2006 Do you have a timeout for inactivity? Quote Link to comment Share on other sites More sharing options...
xyn Posted September 25, 2006 Author Share Posted September 25, 2006 Sorry If i explained badly, The problem is, I wanted to createa 5 minute inactivity, which means when my sessions checkingpage reloads (as it does on every page inside the acp) then thetimestamp changes. So if 5 minutes pass and they don't changetheir page I want the time stamp to reconise 5 minutes inactivityand tell them heir not active, and sign them out :/I can do everything else, just not sure about the time stamp.My clock / time format is(H:i:s) which is 00:00:00(0-24 hr; 0-59mins; 0-59 secs) Quote Link to comment Share on other sites More sharing options...
Barand Posted September 25, 2006 Share Posted September 25, 2006 If you are using H:i:s the you need to convert to timestamp with strtotime() before you do any maths.[code]<?php$saved_time = $_SESSION['saved_time'];$time_now = time();$time_since_last_used = ($time_now - strtotime($saved_time)); // convert to tstampif ($time_since_last_used > 300) { echo "Over 5 mins<br>"; // clear session data // transfer to login}else { $_SESSION['saved_time'] = date('H:i:s', $time_now); // convert to H:i:s}?>[/code]Or you could just save the timestamp value so you don't need to convert backwards and forwards. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.