Page 1 of 1

Passing session data

Posted: Thu Apr 09, 2009 10:53 am
by warznorth
Ok I have 2 pages 1st page is public and second page can only be called by link on first page.

here is my code for 1st page

Code: Select all

session_start();
$_SESSION['pass']="allow";
 
echo "<a href='page2.php'>click for page 2</a>"
And code for 2nd page

Code: Select all

if ($_SESSION['pass'] != "allow") { echo"Cannot call from that page";exit;
 
}else {
 
 
 
echo"this is page2";}
It doesnt work what am I doing wrong?
Im new at this sorry for the dumb question.

Re: Passing session data

Posted: Thu Apr 09, 2009 11:32 am
by watson516
You need to put session_start() on every page that uses sessions

Re: Passing session data

Posted: Thu Apr 09, 2009 11:46 am
by warznorth
Simple

It works now