Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session troubles 1

Status
Not open for further replies.

LaundroMat

Programmer
Dec 2, 2003
67
BE
I've got a little login script setup, but I'm stumped when it comes to session handling.

The first script collects the data in a form (main.php) and sends it to checklogin.php. This script compares the data entered with what's in the database. If all's ok, it copies the userID and nickname to session variables and then it includes a script called message.php. message.php creates a html page with a message plastered on (something like: "logged in fine!"). The HTML has a header redirecting the user to the main page after 5 seconds.

Now, tracking $_SESSION shows that up until the message.php script the session variables are not empty (ie they contain user id & nickname). After the redirection (a META tag in the HTML header of the message.php output), the session is empty.

The page message.php redirects to is the main page (main.php), and that page has a session_start() in it.
 
Every script which needs to manipulate a session variable needs to invoke session_start(). Without that, $_SESSION does not get populated.

The exception is a PHP installation where the php.ini configuration directive session.auto_start is set to 1. Then every script automatically invokes session_start().


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
sigh...

Ofcourse. I forgot to start the session in the script that sets the session vars.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top