Page 1 of 1
Sessions
Posted: Thu Sep 27, 2007 1:05 am
by Zeyber
I am trying to save something from the text field as a session variable. It doesnt seem to be working
First page has:
Code: Select all
session_start();
//Username Entered
$accuser = $_POST["name"];
$_SESSION['user']=$accuser;
Second Page has:
Nothing appears to be showing on the second page
Re: Sessions
Posted: Thu Sep 27, 2007 1:34 am
by Christopher
Second Page has:
Code: Select all
session_start();
echo $_SESSION['user'];
Posted: Thu Sep 27, 2007 1:42 am
by Zeyber
Now I get an error:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/www/???/logindone.php:10) in /home/www/???/logindone.php on line 11
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/???/loginpassdone.php:10) in /home/www/???/loginpassdone.php on line 11
This is how it goes anyway:
login.php (text field)
(First page) logindone.php (session)
loginpass.php (text field)
(Second page) loginpassdone.php (session)
Posted: Thu Sep 27, 2007 8:18 am
by feyd
Search high and low for the phrase "headers already sent". It's a popular theme.
Posted: Thu Sep 27, 2007 5:03 pm
by Zeyber
I don't quite see how that helps

Posted: Thu Sep 27, 2007 5:09 pm
by shylor
When the header function is sent twice that error will happen. So you might have this line in your main file and in another file that is included to the first file.
and with sessions starts, they must always be on the top of the page at hand. you must open the php page and start the session. sessions starts must be on every page too! if you have a config.inc.php they might not be needed if its always included into another file.
Posted: Thu Sep 27, 2007 5:24 pm
by Zeyber
It worked! Thanks so much! You have led a little spirited soul towards the light!
Posted: Thu Sep 27, 2007 7:08 pm
by shylor
No problem, glad to help!