Session variables not holding from page to page
Posted: Fri Apr 18, 2008 1:05 pm
This is starting to drive me crazy...tried scouring the Internet and forums but can't figure it out.
I have an existing website on this Apache webserver that is passing Session Variables just fine...
I am creating a new site, and copied the basic framework from the existing site but for some reason session variables aren't being passed.
My code for home.php (where it registers the vars) is this:
-----{snip}
<?php
session_start();
header("Cache-control: private");
$userlogin = $_GET['userlogin'];
// REGISTER SESSION VARIABLES FOR USER
// ------------------------------------------------
$_SESSION['userlogin'] = $userlogin;
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['emailaddr'] = $emailaddr;
echo 'User login session var is ' . $_SESSION['userlogin'];
echo '<br><a href="page1.php">Click here to see what happens</a>';
exit();
-----{snip}
And, my page1.php code is this:
-----{snip}
<?php
session_start();
header("Cache-control: private");
echo "Session is: ";
echo $_SESSION['userlogin'];
exit;
?>
-----{snip}
Home.php shows the following output:
User login session var is srace
Click here to see what happens
Page1.php shows the following output:
Session is:
Any help is appreciated! I'm 2 days into trying to figure this out and driving me nuts! Thanks!!
I have an existing website on this Apache webserver that is passing Session Variables just fine...
I am creating a new site, and copied the basic framework from the existing site but for some reason session variables aren't being passed.
My code for home.php (where it registers the vars) is this:
-----{snip}
<?php
session_start();
header("Cache-control: private");
$userlogin = $_GET['userlogin'];
// REGISTER SESSION VARIABLES FOR USER
// ------------------------------------------------
$_SESSION['userlogin'] = $userlogin;
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['emailaddr'] = $emailaddr;
echo 'User login session var is ' . $_SESSION['userlogin'];
echo '<br><a href="page1.php">Click here to see what happens</a>';
exit();
-----{snip}
And, my page1.php code is this:
-----{snip}
<?php
session_start();
header("Cache-control: private");
echo "Session is: ";
echo $_SESSION['userlogin'];
exit;
?>
-----{snip}
Home.php shows the following output:
User login session var is srace
Click here to see what happens
Page1.php shows the following output:
Session is:
Any help is appreciated! I'm 2 days into trying to figure this out and driving me nuts! Thanks!!