sessions how to check for inactivity

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
deepinlife
Forum Newbie
Posts: 1
Joined: Sun Oct 26, 2008 1:24 am

sessions how to check for inactivity

Post by deepinlife »

guys ,
i use this piece of code to check if the page is active , i put it in every page in my project , in a case it has failed , why ?

Code: Select all

 session_start();
                if( !$_SESSION['UserToProcess']  )
                {header("Location: logout.php");}
should i use

Code: Select all

 session_start();
                if( isset($_SESSION['UserToProcess'])  )
                {header("Location: logout.php");}
when the page is active all the variables is lost isn't it so the first case should work ?
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: sessions how to check for inactivity

Post by yacahuma »

I use

Code: Select all

  if(!isset($_SESSION['USER']))
        header....
Post Reply