Page 1 of 1

PHP Sessions I am doing something fundamentally wrong

Posted: Thu Apr 05, 2012 2:17 pm
by wmarcy
I have been beating my head against the wall with sessions.

I do have the <?PHP session_start(); ?> as the first line of my file, no white space, nothing before it.

Then, I set the Session array like:

<?PHP
session_start();
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $_POST['password'];
?>

Then In another page, I have the <?PHP session_start(); ?> again as the first line, then I have this code to simply print out the variables:

<?PHP
session_start();
echo "Email= ". $_SESSION['email'];
echo "Password= ". $_SESSION['password'];
?>

And I get nothing. Any ideas what I should look for?

Re: PHP Sessions I am doing something fundamentally wrong

Posted: Thu Apr 05, 2012 2:23 pm
by tr0gd0rr
Do you see the same session cookie in your browser for both pages? (e.g. in firebug run `document.cookie` on the console)

Re: PHP Sessions I am doing something fundamentally wrong

Posted: Fri Apr 06, 2012 5:21 pm
by xtiano77
Can you post the code in question? I mean the code from the page with the <form> as well as the code from the next page where the session is called and the values assigned.