I tried the following code:

<?php

header("WWW-Authenticate: Basic realm=\"My Realm\"");
header('status: 401 Unauthorized');

print "Logout Successfull";
?>

Now I am getting a the same window for filling up the user id and password that I got first to log in to my web site as I used .htaccess file in side the MainPage directory.

And if I press cancel it's giving me:

Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.

If I press ok without inputting any thing it gives me:

"Logout Successfull"

Even I tried to fillup the user ID and password and press ok it gives me "Logout Successfull". I assume it's asking me the same user ID and Password that I used for the first login to for .htaccess file.

But I don't want none of the above situations.

Let me tell you my goal. I think that might help you to understand what I really want to do.

I want to use some php code that will log me out from this web site and no matter how many pages are open from the same web sire (Those will be inactive). I mean you have to login again to get atarted again. Just think about hotmail. If it has open several pages from same user account. If you logout one of the page the others are required t olog in again on order to do something.

Hope you understand. Plese let me know your advice.

    I don't think you can log out of HTTP based authentication unless you close the browser.

    If you are going to use HTTP based authentication though, you will need a password file... else what are you authenticating against? That's why you're able to enter anything and it says authentication successful.

    What you are after though, is not HTTP based authentication... you want to use a database, and php and sessions, to code up a authentication script.

    There's squillions of threads and tutorials on this throughout the site... have a look around, and there's more then enough info to get you going.

    good luck.
    -Adam 🙂

      I also think so that I have to implement PHP code to do that, but how? Any idea. I tried to find some info from web sites but did not get enough. Any suggestion.

        Write a Reply...