• You are not logged in. | Login

Post a reply

January 17, 2007 12:36 pm

shadow122
Member
Ranks

Quit the session

Authorization via browser's sessions like:

if (isset($_SERVER["PHP_AUTH_USER"])) {
$user=$_SERVER["PHP_AUTH_USER"];
$pass=$_SERVER["PHP_AUTH_PW"];
} elseif
(isset($_SERVER["HTTP_AUTHORIZATION"])) {
if (substr($_SERVER["HTTP_AUTHORIZATION"],0,5)=="Basic") {
$userpass=split(":",base64_decode(substr($_SERVER["HTTP_AUTHORIZATION"],6)));
$user=$userpass[0];
$pass=$userpass[1];
}
}
$auth=false;
 
$result=mysql_query($sql)  or die("Invalid query: " . mysql_error());
while ($res=mysql_fetch_array($result)) {
if ($user==$res["login"]&&crypt($pass,"pw")==$res["passw"]) {
$user_id=$res["id"];
$auth=true;
break;
}
}
if (!$auth) {
header("WWW-Authenticate: Basic realm=\"Protection area. Enter your information:\"");
header("HTTP/1.0 401 Unauthorized");
}

Everything works but I need to create the "Quit" button to quit the session and login by another user. But how should I tell browser that I want to quit, can't understand, please help


 

 

January 17, 2007 12:48 pm

phppat
Member
Ranks

Re: Quit the session

Passwords are stored in the browser's window. Delete that window and create new one


PHP monster

 

 

January 17, 2007 1:03 pm

R@mzess
Member
Ranks

Re: Quit the session

Try to describe how everything works in that example and what messages server and browser exange
I think you'll understand


 

 

January 17, 2007 1:05 pm

phppat
Member
Ranks

Re: Quit the session

To send the unauthorized header. When I first faced with it i understood that that method is not for me. I don't use it


PHP monster

 

 

January 17, 2007 1:06 pm

shadow122
Member
Ranks

Re: Quit the session

R@mzess, How??

Last edited by shadow122 (January 17, 2007 1:09 pm)


 

 

January 17, 2007 1:08 pm

shadow122
Member
Ranks

Re: Quit the session

phppat, I send unauthorised header, user will ask for the authorization and browser will give him
saved data, won't it?


 

 

January 17, 2007 1:09 pm

phppat
Member
Ranks

Re: Quit the session

Try, then search. After that try again


PHP monster

 

 

January 17, 2007 1:12 pm

shadow122
Member
Ranks

Re: Quit the session

phppat, unauthorized header is

header("WWW-Authenticate: Basic realm=\"Protection area\"");
header("HTTP/1.0 401 Unauthorized");

appears the browser's window. But it isn't required, I have to redirect to index.php and to close the session


 

 
  • Actions
  • Top
ITCrimea. Ukraine Web Development Company. Professional Developers and Web Designers Team
Custom Web Designs, Internet Applications, E-Commerce Websites, Interactive Sites, Database-Driven Sites and Services