Re: Re[2]: [PHP] timer on sessions?
| From: | Jas | Date: | Wed, 17 Jul 2002 16:11:56 +0000 |
| Subject: | Re: Re[2]: [PHP] timer on sessions? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108109@lists.php.net to get a copy of this message | ||
So under the time() call, comparing it to a simple numerical value such as
"300" it knows that you are talking about 300 seconds? Is that because it
is a unix timestamp? I previously tried using date("s") to give me the
seconds from today's date then tried the compare, so using time() will work
better. Thanks a ton.
Jas
"Asmodean" <asmodean@lka.nu> wrote in message
news:14814144515.20020717180945@lka.nu...
> J> I am not able to test from this machine so please tell me if I am right
or
> J> wrong on this:
> J> $tmp = time();
> J> $tme = time() - 5*60;
> J> session_register('tmp');
> if ($tmp >>= $tme) {
> J> echo 'Time has not reached 5 minutes, session still valid';
> J> } else {
> J> echo 'Timer has reached 5 minutes, you will need to log back in to
> J> continue.'; }
>
> J> "Asmodean" <asmodean@lka.nu> wrote in message
> J> news:8312607156.20020717174408@lka.nu...
> >> J> Not sure how to go about setting up a function to parse the date,
hour,
> >> J> minutes, seconds, take the seconds and register them in a session
var,
> J> then
> >> J> do a check on the session var (seconds) vs. the seconds var + 5*60
(or
> J> 5
> >> J> minutes) to time out the session and force the user to log back in.
My
> >> J> problem is finding the correct way to check the seconds in php. Any
> J> help or
> >> J> pointers is appreciated.
> >> J> Jas
> >>
> >> time() will give you a UNIX timestamp. Use it to do the math.
> >>
> >> --
> >> Best regards,
> >> Asmodean
> >> mailto:asmodean@lka.nu
> >>
>
> Let's assume you've set your session timestamp (assume it's called
> $session_time) to time() at the time of login. Now, in the script...
>
> if ((time() + 300) > $session_time) {
>
> }
>
> This would be a check to see if the session is still valid. Timewise.
>
> --
> Best regards,
> Asmodean mailto:asmodean@lka.nu
>