View Full Version : Problems calling a session

03-10-2008, 01:23 AM
The problem i have really confuses me.

When i classify a session to the user (in either the login.php or register.php page) the page userarea.php displays properly.

If i then refresh the page or click a link to userarea.php all the info disappears.

I have tried echoing the session variable to see whats going on and instead of being "1" (the users id number) the variable changes to "Array" once refreshed.

I never actually touched the variable and all three pages have session_start(); in them. :confused:

Any ideas?

03-10-2008, 01:28 AM
Find out what's in the session variable:

It's being modified somewhere in the file(or one that it includes). Do a search for $_SESSION in your file(s).

03-10-2008, 03:29 AM
It is likely that the session is not starting. Add the following two lines after the first opening <?php tag to get php to help you -

ini_set ("display_errors", "1");

03-10-2008, 06:22 PM
Thanks for the error reporting code. I probably should just leave that in for good practice.

I found the error too. I was calling a variable called $username and my session was called $_SESSION['username'] which for some reason made itself break.

Is there a way of turning this off?


03-10-2008, 06:57 PM
That's due to register globals being on. Turn them off or use unique names for all program/post/get/cookie/session variables.

In addition to being a security risk by intentionally populating same name variables from external variables, register globals also causes unintentional overwriting of same name variables even if you don't want them to be.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum