Jump to content


Photo

Timestamp Query!!


  • Please log in to reply
4 replies to this topic

#1 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 24 September 2006 - 06:49 PM

Hey guys,
Just have a short, quick querstion. I have a admin control unit
and I wanted to add a 5 minute inactivity, everytime the page
is refreshed (uses another page within the acp) The time stamp
is updated

Yet if the admin leaves their accoutn for over 5 minutes when
they refresh the page it checks the Current time with the timestamp
and it tells them they're not logged in?

My clock formatt is... H:i:s, (00:00:00) could someone give me a small
pointer on how to fix this.
Thanks!

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 24 September 2006 - 08:27 PM

How to fix what ? Clock format?

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 WendyLady

WendyLady
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 24 September 2006 - 10:04 PM

Do you have a timeout for inactivity?

#4 xyn

xyn
  • Members
  • PipPipPip
  • Advanced Member
  • 779 posts
  • LocationNorthampton

Posted 25 September 2006 - 06:07 AM

Sorry If i explained badly, The problem is, I wanted to create
a 5 minute inactivity, which means when my sessions checking
page reloads (as it does on every page inside the acp) then the
timestamp changes. So if 5 minutes pass and they don't change
their page I want the time stamp to reconise 5 minutes inactivity
and 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)

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,025 posts

Posted 25 September 2006 - 09:14 AM

If you are using H:i:s the you need to convert to timestamp with strtotime() before you do any maths.

<?php
$saved_time = $_SESSION['saved_time'];

$time_now = time();

$time_since_last_used = ($time_now - strtotime($saved_time));  // convert to tstamp

if ($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
}
?>

Or you could just save the timestamp value so you don't need to convert backwards and forwards.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users