Issue resolved... For some reason if the $request_uri was empty, the redirect failed because it was going to itself. I enclosed the redirect around an if statement checking the request_uri variable. BTW, $request_uri is a hidden form variable that captures the actual $REQUEST_URI global variable when the login form appears. This allows me to redirect the user to the requested page when they log in. Works like a charm!!!
Sometimes in explaining the problem, I see the solution. ----- Original Message ----- From: Dennis Moore To: [EMAIL PROTECTED] Sent: Monday, May 13, 2002 5:29 PM Subject: [PHP] Session Login and Redirect Problem I am using Sessions with mod PHP4.0.6 with trans-sid set on. Everything works fine. However, after loggin in, I want to automatically redirect the user to a specific page if they came from an external site or were given a link via emal. I realize that a session variable is not actually stored until the end of the script. So I used the session_write_close() function to save the session before redirecting using the header() function. It does not work. The session variable fail to be available after redirection. Any ideas? ================================================================ <?php if (!session_is_registered("valid_user") && $session_login=="proc"){ if ($userid && $password) { // if the user has just tried to log in $query = "select * from auth_users " ."where auth_username='$userid' " ." and auth_password='$password' and active='Y'"; $result = mysql_query($query) or die("MySQL Login Error: ". mysql_error() ); if (mysql_num_rows($result) >0 ) { // if they are in the database register the user id $valid_user = $userid; $valid_group=mysql_result($result,0,"auth_group"); $valid_perms=mysql_result($result,0,"auth_perms"); $valid_auth_id=mysql_result($result,0,"auth_id"); session_register("valid_user"); session_register("valid_group"); session_register("valid_perms"); session_register("valid_auth_id"); /* Redirect browser */ session_write_close(); header("Location: http://".$SERVER_NAME.$request_uri); exit; // exit script } else { $invalid_login= "Invalid login: Could not log you in... <!--ERROR: $dbname <P> $query-->"; } } } ?> ------------------------------------------------------------------------------ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php