Re: Basic Auth
| From: | Stuart Dallas | Date: | Tue, 27 Aug 2013 13:46:09 +0000 |
| Subject: | Re: Basic Auth | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321991@lists.php.net to get a copy of this message | ||
On 27 Aug 2013, at 14:37, Jim Giner <jim.giner@albanyhandball.com> wrote:
> I"m using basic auth for a few of my pages that I want to limit access to - nothing of a
> sensitive nature, but simply want to limit access to. Want to implement a signoff process, but
> can't figure it out.
>
> From the comments in the manual I take it one can't do this by simply unsetting the
> PHP_AUTH_USER and _PW vars. Can someone explain to me why this doesn't suffice? The signon
> process expects them to be there, so when they are not (after the 'unset'), how come my
> signon process still detects them and their values?
The global variables you're referring to are just that, global variables; changing them will
have no effect on the browser. Basic Auth was not designed to allow users to log out, but you can
make it happen with some Javascript.
Have your log out link call a Javascript function which sends an XMLHttpRequest with an invalid
username and password. The server will return a 401 which you ignore and then take the user to
whatever URL you want them to see after they log off. Not pretty, but it works.
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/