Authentication, multiple cookies

From: Date: Tue, 05 Sep 2000 13:55:29 +0000
Subject: Authentication, multiple cookies
Groups: php.general 
Request: Send a blank email to php-general+get-15290@lists.php.net to get a copy of this message
I'm trying to enable user authentication on a group of web pages with different levels of access. I'm using $PHP_AUTH_USER as well as a series of other cookied variable, $USER, $STAFF, and $ADMIN , each set to "true" when the appropriate login happens, but I can't seem to get it to work. I've been at this for several days to no avail. If anyone knows why, please help. Here's more or less what my last iteration looks like: login.php3: <?PHP if((!($PHP_AUTH_USER)) | ($ADMIN!="true")): Header("WWW-authenticate: basic realm=Something"); Header("HTTP/1.0 401 Unauthorized"); echo "<meta http-equiv=\"refresh\" content=\"0;url=failed.html\">"; exit; else: $conn=mysql_connect("localhost","something","something"); mysql_select_db("db",$conn); if (!conn) {echo "An error occurred in connection.\n";exit;} $user_id=strtoupper($PHP_AUTH_USER); $password=$PHP_AUTH_PW; $result=mysql_query("SELECT * FROM clients WHERE email='$user_id' and password='$password'",$conn); if (!$result): echo "An error occurred.\n"; exit; endif; $num=mysql_NumRows($result); if (mysql_NumRows($result)>0): SetCookie("BRC1",$user_id,time()+0); SetCookie("BRC1",$user_id,time()+0,"/",".some.domain"); SetCookie("ADMIN","true",time()+0); SetCookie("ADMIN","true",time()+0,"/",".some.domain"); echo "<meta http-equiv=\"refresh\"content=\"0; url=index.php\">"; exit; else: Header("WWW-authenticate: basic realm=Something"); Header("HTTP/1.0 401 Unauthorized"); echo "<meta http-equiv=\"refresh\" content=\"0;url=failed.html\">"; exit; endif; endif; ?> and at the top of the protected document: <?PHP if((!($PHP_AUTH_USER)) | ($ADMIN!="true")):
    echo "<meta http-equiv=\"refresh\"
      content=\"0;url=login.php3\">";
    exit;
else: echo "Hidden contents"; exit; ?> Whenever I try to log in, it sends me to failed.html. If I remove the $ADMIN bit and just go with the $PHP_AUTH_USER it works fine. Age -- ------------------------------------------------------------ Adriano "Age" Manocchia am33@cornell.edu Cornell University AIM: BigRedWhat http://www.hockey.cornell.edu/age ------------------------------------------------------------ "The capacity to blunder slightly is the real marvel of DNA. Without this special attribute, we would still be anaerobic bacteria, and there would be no music." -Lewis Thomas

« previous php.general (#15290) next »