SESSION PROBLEMS

From: Date: Sun, 27 Apr 2003 22:04:27 +0000
Subject: SESSION PROBLEMS
Groups: php.general 
Request: Send a blank email to php-general+get-145438@lists.php.net to get a copy of this message
hi, I am new to php and I have recently started using sessions. I am getting some unusual behavior that I am unable to figure out. Currently, I have a validate page that starts a session. If the user is validated, then the user is re-directed to another page called main.php in another directory. code: validate.php <?php session_start(); //open connection $connection = mssql_connect....or die ("Couldn't make connection."); //open database $db = mssql_select_db... or die("Couldn't select database."); $query = "Select * from employees where name = '$userName' and password = '$password'"; $result = mssql_query($query, $connection) or die("Couldn't execute query."); $row = mssql_num_rows($result); if($row != 0) { $row=mssql_fetch_array($result); session_register("valid_user"); $valid_user=$row["id_num"]; session_register("name"); $name=$row["name"]; session_register("type"); $type=$row["type"]; header("Location: ../employee_mngr/main.php"); exit; } else { } ?> For some reason, however, when I reach the re-directed location, the session does not seem to be valid. To make things even more confusing for me, If I hit the back button once I have reached the re-directed page and I then attempt to re-login, the session is valid now. code: main.php <? session_start(); //STOPS USER FROM BYPASSING LOGIN SCREEN if(!session_is_registered("valid_user")) { echo "The session is not registered!!!"; //header("Location: https://.........."); exit; } ?> Thanks, Dale

« previous php.general (#145438) next »