session question

From: Date: Fri, 23 Feb 2001 18:53:27 +0000
Subject: session question
Groups: php.general 
Request: Send a blank email to php-general+get-41352@lists.php.net to get a copy of this message
I have a form that submits to abc.php which then calls db.php and db.php then redirects to a new URL. I have session_start(); on all these files and I'm registering the variables I need. It seems that the session dies or gets lost on it's way through all the included files. I then tried to pass the SID in the URL that the db.php file creates, but the SID is empty once it gets here...though, there is a SID befoer then. Can sessions not be used with multple include files? What could I be doing wrong? This is my first forray into sessions...be gentle! thanks! Some code below, it's prettry straight forward. I still have cookies enabled, as well. Do I need to disable cookies for the SID in URL method to work? index.php where they log in from <? session_start(); //first line of file ?> <form method="POST" action="main.php"> <input type="hidden" value="lrlogin" name="form_action"> Username&nbsp;&nbsp;<input type="text" name="username" class="color"><br /> Password&nbsp;&nbsp;<input class="color" type="password" name="password"><br /> <input type="reset">&nbsp;&nbsp;&nbsp;<input type="submit" value="Login"> code from main.php <? session_register(); require ("db.php"); if $form_action == "lrlogin" { get_user($username,$password); } ?> code from db.php <? session_start(); SQL to select user info from db $access = $row[access_level]; //etc getting vars from db session_register("username"); session_register("password"); session_register("access"); session_register("active"); header("Location:http://www.blah.com/index2.php?=".SID); exit; ?> index2.php code <? session_start(); print "Welcome $username"; ?> it only prints Welcome ...no username :(

« previous php.general (#41352) next »