Page 1 of 1

Session Variables Don't work

PostPosted: 20. April 2005 17:24
by whitets
I have installed Xampp on my home computer (laptop) and it works great. Kudos to the developers. After trying to coordinate Mysql and PHP and Apache for 2 days, I installed this in 10 minutes!

However, I have found that session variables don't work. The pages I installed on my main web server online work just fine so it probably isn't the code. The session.auto_start variable in php.ini is set to 0 which is correct. I have put session_start(); at the top of my pages. I set the session variable with:

$_SESSION['menu'] = "officer";

If I check on that page the $_SESSION variable is set.

On the next page I try to read the variable as:

$menu = $_SESSION['menu']

$_SESSION['menu'] is null at that point.

Any ideas of setting to change?

Thanks.

Stan White

PostPosted: 20. April 2005 19:09
by taustin
I am far, far from an expert on this, but the example code I started with has a session_register between session_start and assigning values. IIRC, it is absolutely required.

PostPosted: 20. April 2005 19:32
by whitets
Thanks, Taustin. However, session_register() isn't required. I have never used it on other servers and the pages work just fine there. I did try it here again, but to no avail.

Stan White

PostPosted: 20. April 2005 19:46
by Wiedmann
On the next page I try to read the variable as:

How did you go to the next page?

(Think about the SID...)

PostPosted: 20. April 2005 19:51
by whitets
I use

echo "<script language=javascript> parent.location.href='index.php'; </script>;

to go to the next page.
I checked the SSID on several pages after starting the session and the number changes with each page so the session didn't actually take.

I am using localhost for my server. I read a hint somewhere that all links must use www. at the front. Is this true? I don't use that anywhere on my online server and everything works just fine there.

thanks.

PostPosted: 20. April 2005 20:05
by whitets
I found the problem. I use Zonealarm as my firewall. It has a site in the Privacy/Site List labelled Loopback which, as I understand it, is a program 'looping back' to 127.0.0.1 - i.e my computer. I had the settings for the Loopback set for enabling Mobile Code, Allowing cookie Control Session and Persistent, but not allowing for 3rd party. I changed that last setting to allowing 3rd party for Loopback and it now works just fine. 8-)

Stan