PHP Sessions I am doing something fundamentally wrong

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
wmarcy
Forum Newbie
Posts: 3
Joined: Fri Mar 23, 2012 3:25 pm

PHP Sessions I am doing something fundamentally wrong

Post 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?
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: PHP Sessions I am doing something fundamentally wrong

Post 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)
xtiano77
Forum Commoner
Posts: 72
Joined: Tue Sep 22, 2009 10:53 am
Location: Texas

Re: PHP Sessions I am doing something fundamentally wrong

Post 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.
Post Reply