Joesavage Posted September 17, 2007 Share Posted September 17, 2007 I am having a problem transfering the value of one of my session variables from one page to another.This is the page where I want to set the php variable $_Session['ONE']. This page is called index.php. Here is the code for index.php:<?phpsession_start();?><html><body bgcolor = "#ffffcc"><?php$_Session['ONE'] = 1;echo $_Session['ONE'];?> and abunch more irrelevant code.index.php prints out the value one and the result of all the other irrelevant code.I want to call the variable $_Session['ONE'] on another page called OutsideAccount/make_account.php. I am not sure if this matters but the page make_account.php is in a subdirectory of the folder that index.php is in.The code for OutsideAccount/make_account.php:<?phpsession_start();?><html><?phpecho $_Session['ONE'];?><body bgcolor = "#ffffcc"> and abunch more irrelevant code.This page only prints out the result of the irrelevant code, it does not print the value 1.Does anyone know why? I thought this would be very simple, but it is turning out to be very frustrating. Link to comment Share on other sites More sharing options...
Synook Posted September 17, 2007 Share Posted September 17, 2007 Umm... the variable is $_SESSION, not $_Session (capitalization matters). Like how you are doing it, you are just creating a new normal array called $_Session, but it won't be passed from page to page.Also, in make_account.php, you are echoing the variable outside the <body> tag, and some browsers won't display it. Link to comment Share on other sites More sharing options...
jhecht Posted September 17, 2007 Share Posted September 17, 2007 and also, usually when you use sessions, you have to set all the variables BEFORE anything is outputted to the browser. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2007 Share Posted September 17, 2007 You don't have to set the variables, that happens on the server, before you send any output all you need to do is start the session and send the cookie. Everything else happens on the server. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.