Page 1 of 1
Unable to print out session variables
Posted: Wed Sep 27, 2006 3:23 pm
by impulse()
I have checked that sessions are enabled in the php.ini file, which it is, and I'm unable to print out any data stored inside of the $_SESSION variable.
On page example1.php I have:
Code: Select all
session_start();
$_SESSION["Name"] = "Stephen";
echo $_SESSION["Name"];
And on page example2.php I have:
Code: Select all
session_start();
echo $_SESSION["name"];
Can you see what I'm missing or where I'm going wrong?
Regards,
Posted: Wed Sep 27, 2006 3:26 pm
by MrPotatoes
1. you don't need to openthe session each time if it's being included into that page.
2. name should be the same case as the actual index
so the second page should be "Name" not "name"
Posted: Wed Sep 27, 2006 3:31 pm
by impulse()
Ahh, I should've spotted that one
Even still it doesn't display anything though.
Posted: Wed Sep 27, 2006 3:35 pm
by volka
Posted: Wed Sep 27, 2006 3:38 pm
by impulse()
Still nothing.
It could be because I have to access my site through an online proxy. If I go straight to my domain or IP I get my routers setup page. Would you mind trying for me.
http://stesbox.co.uk/php/session.php - Creates session variable on this page, also shows it.
http://stesbox.co.uk/php/session2.php - Echo and print_r the session variable.
Posted: Wed Sep 27, 2006 3:39 pm
by kendall
Is the session being created/ stored in the first place?
maybe your using a lower version and should be HTTP_SESSION_VARS?
Edit::: ok i just checked it out...its working sor i guess its that proxy thingy whatever...
Posted: Wed Sep 27, 2006 3:41 pm
by SpecialK
Both of those links print out 'Stephen' for me.
Posted: Wed Sep 27, 2006 3:43 pm
by volka
Why don't you setup a webserver on your local pc?
e.g. with
http://www.apachefriends.org/en/xampp.html
Posted: Wed Sep 27, 2006 3:45 pm
by kendall
Aaahh xampp...its good...sigh

Posted: Wed Sep 27, 2006 3:54 pm
by impulse()
Don't know. It'll just be hassle to FTP over the complete files to the live web server once they're complete.
I'm writing 2-3 full working scripts at the minute and loads of few lines scripts for learning and testing.
Posted: Wed Sep 27, 2006 3:58 pm
by MrPotatoes
btw, i was having serious session/cookies problems when i was creating my system locally. make a quick script to delete your sessions and clear your cookies and everything on your browser(s)
Posted: Wed Sep 27, 2006 4:00 pm
by volka
impulse() wrote:Don't know. It'll just be hassle to FTP over the complete files to the live web server once they're complete.
I'm writing 2-3 full working scripts at the minute and loads of few lines scripts for learning and testing.
And why do you want to upload your two-lines-learning-scripts to a "live server"?
Posted: Wed Sep 27, 2006 4:30 pm
by panic!
I always prefer to write local and upload when finished if possible. Waiting 5 seconds to upload every time you make a little change and then having to load the page from the server is a pain.