jlisec01 — 2010-05-18T19:59:07-04:00 — #1
Hi there, I was wondering if there was a script that to logg a user off? Im using apache and I set the directory to allow a username and password, and since apache doesn't allow to log off unless you close your browser or something, what could I do to have a link when click would run the script to log the person off? thanks for any help.
dan_grossman — 2010-05-19T01:23:22-04:00 — #2
No. HTTP basic authentication involves the browser sending the encrypted username and password with each request. There is no actual state, no "logged in" and "logged out" status. The user becomes "logged out" after closing the browser simply because the browser stops remembering the username/password that was provided to send with each request. So there is nothing server-side you can do to log someone out, short of deleting their access entirely.
Now if you program your own authentication scheme using sessions or cookies rather than HTTP authentication, you can delete the session to log the user out.