homepage Welcome to WebmasterWorld Guest from 54.167.11.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
.htaccess logout works
Apache login logout way to do it
FrankReinecke




msg:435695
 8:11 pm on Jul 22, 2003 (gmt 0)

Hi There!

Some time ago there were some questions about how to realize a logout from realms protected by .htaccess files without having to close the browser and empty all cached files (which most users don't do, even if they sould!).

Here's what I found out:

[I have read this one elsewhere and used it]

1. Create another realm which is protected by .htaccess
2. Create .htpasswd-file for it
3. Create a "dummy" user, mine is "logout:logout"

Now put a file into that directory that sends html-standard-code 401 Unauthorized! I do it using perl/cgi like this:


--- perl code ---

use CGI qw/:standard/;
print header(-status=>'401 Unauthorized');

--- end of code ---

Now you only have to create a link point to that file:


<a href="logout:logout@url://../logout.cgi">LOGOUT!</a>

.. and BANG it works!

You can even keep the browser running, the browser will even have some of the protected pages in cache, but every new "reload" causes a new authorization procedure!

I use this to protect an cgi-application that often changes values and is reloaded several times for this purpose (calls itself with changed input-field-values). For this kind of content it works perfectly!

Hope someone find's this helpful, I was puzzling a whole night to find that out - and it's soooo easy, once you know how it's done!

Anyway...

e-mail replies:

[edited by: jatar_k at 4:17 pm (utc) on July 23, 2003]
[edit reason] email in profile thanks [/edit]

 

sugarkane




msg:435696
 9:31 pm on Jul 22, 2003 (gmt 0)

Frank - thanks for that, looks like a good tip. It'll certainly come in handy when testing applications that rely on htaccess authorisation, when you want to 'be' multiple users...

Oh, and welcome to WebmasterWorld ;)

Storyteller




msg:435697
 1:59 am on Jul 23, 2003 (gmt 0)

This is definitely a useful technique, but doing it without external scripts, by sending a 401 response using mod_rewrite, would be even more elegant.

Is anyone doing this already?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved