Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Logoff/ReLogin to htaccess in one browser

by hatter (Pilgrim)
on Jul 10, 2002 at 11:17 UTC ( #180724=note: print w/replies, xml ) Need Help??

in reply to Logoff/ReLogin to htaccess in one browser

I gave up looking for solutions to this problem, once I moved over to using more complicated authentication (my current back end intrinsically allows a prived user to pretend to be a lesser one) So as you'd expect, a solution prevented itself late one night shortly after.

What you need to do is force your webserver to report a 401 error (authentication required) This is the same as it normally reports when you try to access a protected directory, and your browser should then assume the credentials it previously supplied are no longer correct, and prompt you for username and password.

I suggested this to a friend having similar difficulties finding how to do it, and he reckons it works just peachy, except for a bug in one version of IE5.

the hatter

Replies are listed 'Best First'.
Re: Forcing Apache to spit out a 401
by LAI (Hermit) on Jul 10, 2002 at 13:33 UTC
    Good idea, hatter. But how would you do that? How would you force a 401? Can you do it by writing to the HTTP header directly? I'd love to see some code.


      With, you ought to be able to do something like this untested code:

      use CGI $q = new CGI; print $q->header(-status=>'401 Authorization required'); # add code here to print the rest of the error document
      He seemed like such a nice guy to his neighbors / Kept to himself and never bothered them with favors
      - Jefferson Airplane, "Assassin"

      A link like this might do the job:

      <a href="">logout</a>

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://180724]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2022-01-17 17:13 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (51 votes). Check out past polls.