Log in

View Full Version : Php and Time.....?



Tristan S.S.
02-26-2007, 04:00 AM
Hi all.

Is it possible to, in a php session, stamp the time a user visits a page, so that on other pages it can be echoed? I have tried to use time() but that updates everytime the page loads... Is there a very simple solution...in PHP?

Here's more detail.

Page # 1 starts the session. It must remeber the time it is loaded, then direct to a second page.

Page # 2 checks the url for a key and checks the recorded time. If more than 10 seconds has elapsed, the page directs to an "failed" page, however, if the seconda page is reached within those 10 seconds, the page directs to a "Success" page.

Hope this helps to explain.

Thanks!

thetestingsite
02-26-2007, 04:07 AM
You could probably do something like this on your first page:



<?php
session_start();

$_SESSION['theTime'] = time();

?>


Then on your second page, have something like this:



<?php
$curTime = time() - 10;

if ($_SESSION['theTime'] < $curTime) {
echo 'success';
}

else {
echo 'failed';
}
?>


Not sure if this is what you want, but hope this hleps.

BLiZZaRD
02-26-2007, 04:10 AM
You could also try posting your question once, and in the correct board.

thetestingsite
02-26-2007, 04:14 AM
Ah yes, I didn't even notice this was in the lounge. Also; as said in my post on your other thread, please do not double post. If it is posted in the wrong forum, then the admin (or if/when he gets moderators for the board) will move the thread to the appropriate (spelling?) forum.