Page 1 of 1

http auth.

Posted: Fri Feb 17, 2006 11:47 am
by frederix
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi, here i am with another question ...
This time http auth, more specific the logout of an applicacion logged by this code:

Code: Select all

$auth = false;

if (isset($_SERVER['PHP_AUTH_USER']) &&
    isset($_SERVER['PHP_AUTH_PW'])) {

   $username = $_SERVER['PHP_AUTH_USER'];
   $password = $_SERVER['PHP_AUTH_PW'];
   $oMember->Set('username', $username);
   $oMember->Set('password', $password);
   
   $results = $oMember->SearchUser();
   $number = count($results);
   if($number != 0) {
      $auth = true;
   }
}
if(!$auth) {
   header('WWW-Authenticate: Basic realm="My Auth"');
   header( 'HTTP/1.0 401 Unauthorized' );
   echo 'Authorization Required.';
   exit;
}
else {
   echo 'Welcome ...';
   $_SESSION['member_username'] = $username;
   $_SESSION['member_password'] = $password;
   echo "<meta http-equiv=\"Refresh\"content=\"2; URL=index.php?order=title\">";
}
I cant make a working code for logout.
In my best approachs the login windows appears again on the screen and when i hit enter the user loggout.
The other approach that i am using rigth now is a javascript function who closes the browser.

I need a clean logout for my users, any help will be appreciated.

Thanx.


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Fri Feb 17, 2006 12:51 pm
by feyd
The login information is kept and sent by the user's browser once they get authenticated.

Here's a recent thread on this exact same subject.
viewtopic.php?t=43840