Hello, when I get to logout page, I'd like to remove $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']

How can I get it?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CWS (haripriya)Commented:
unset does not work in this case. You have to send headers to reauth the user, so the remote browser know the credentials are no longer valid , but tat will be very confusing for the enduser

function authenticate() {
    header('WWW-Authenticate: Basic realm="Test Authentication System"');
    header('HTTP/1.0 401 Unauthorized');
    echo "You must enter a valid login ID and password to access this resource\n";

Why do you want to unauth the user in that case?
why not use $_SESSION variables to authenticate, you can't unset $_SERVER variables.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

portal123Author Commented:
Hello, guys.

unset does not work.

To hernst42, Reason what i unauth is when a user can access to admin pages  again he can get in there without id,password.

To nplib, this is for mobile site and some mobile browers do not accept session variables. $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_USER']  are OK on them.

because you can't unset a $_SERVER variable. They exist as part of the server.

why not set these variables to be empty, then test for this emptyness for your login/logout purposes.


if (empty($_SERVER['PHP_AUTH_USER'])) {
   do stuff
} else {
  do other stuff

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
portal123Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.