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