Jump to content

Php Session


Joesavage
 Share

Recommended Posts

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...