Expired session?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Expired session?

Post by Ree »

How can I easily check if user's session has expired?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Expired session?

Post by RobertGonzalez »

Ree wrote:How can I easily check if user's session has expired?

Code: Select all

<?php
if ( isset($_SESSION['var']) )
{
    //session is active
}
?>
Where var is the name of one of the session vars that was set. Relying on PHPSESSID is not always the best idea because sometimes the SESSID changes to 1 (at least in some of my code it has).
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

So simple... Why haven't I thought of this... :oops:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Ree wrote:So simple... Why haven't I thought of this... :oops:
LOL.... I know the feeling :P
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Been there, done that. Believe me I have been stumped by simpler..
everah wrote: Why is this loop crashing my script?

Code: Select all

<?php
$x = 10;
while ($x < 100)
{
    echo "Hi There";
}
?>
By the way, the above code is a great way to fill up your screen and watch your scroll scroll bar shrink and shrink and shrink.
Charles256
DevNet Resident
Posts: 1375
Joined: Fri Sep 16, 2005 9:06 pm

Post by Charles256 »

my personal favorite..in c++..

Code: Select all

for (int i=0;i<5;l++)
{
  do some mad wicked stuff..
}
and could not figure ouyt why it never got out of that loop.... heh
Post Reply