http auth.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
frederix
Forum Newbie
Posts: 3
Joined: Fri Feb 17, 2006 11:45 am

http auth.

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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
Post Reply