Re: HTTP authentication : logout!!!

From: Date: Mon, 07 May 2001 13:16:41 +0000
Subject: Re: HTTP authentication : logout!!!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-51726@lists.php.net to get a copy of this message
It dont work, what you have to do is that: In the logout.php: -------------- <? header( 'WWW-Authenticate: Basic realm="Private"'); header( 'HTTP/1.0 401 Unauthorized' ); ?> <html><body> Logout Sucessful </body></html> -------------- And you have to inform the user to clean the password field, click ok, then the pop-up will open again, then user click in cancel. I just know that way to do. If anyone know another way, Postit! elias wrote: > > Never tried it though...but can you try to empty or unset the > $PHP_AUTH_USER/PWD ? > > -elias > http://www.eassoft.cjb.net > > ""Thomas Edison Jr."" <thomasedisonjr@yahoo.com> wrote in message > news:20010507123919.13046.qmail@web3703.mail.yahoo.com... > > i'm using http authentication for my php pages > > (members area). Once you login correctly, than you can > > access anypage as the authentication box doesn't > > pop-up. > > > > Now i woul like to create a logout link after clicking > > on which, whenever you click on a page using auth, the > > auth box should pop-up again and you must feed in your > > user/pass. What should this logout page contain? what > > coding do i have to do? > > From what i understand, there is a $auth which is > > "False" by default. When auth is succesfull, it > > contains "True". And once it's true, the auth box > > doesn't pop-up. I understand that probably clicking on > > this "logout" link should again make $auth false. But > > then $auth is on a lot of pages, how does this $auth > > on logout.php3 make all the other $auth's false? > > > > or is there some other way? > > > > the code i'm using for auth is : > > > > *** > > <?php > > $auth = false; // Assume user is not authenticated > > if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) { > > > > mysql_connect('localhost','root') or die ( > > 'Unable to connect to server.' ); > > mysql_select_db( 'skynet' ) or die ( 'Unable > > to select database.' ); > > > > // Formulate the query > > > > $sql = "SELECT * FROM register WHERE > > username = '$PHP_AUTH_USER' AND > > password = '$PHP_AUTH_PW'"; > > > > // Execute the query and put results in $result > > > > $result = mysql_query( $sql ) or die ( 'Unable to > > execute query.' ); > > > > // Get number of rows in $result. > > $num = mysql_numrows( $result ); > > if ( $num != 0 ) { > > > > // A matching row was found - the user is > > authenticated. > > > > $auth = true; > > } > > } > > > > if ( ! $auth ) { > > > > header( 'WWW-Authenticate: Basic realm="Private"' > > ); > > header( 'HTTP/1.0 401 Unauthorized' ); > > echo 'Authorization Required.'; > > exit; > > > > } else { > > > > %%stuff 2 do%% > > > > } > > ?> > > *** > > > > Regards, > > T. Edison jr. > > > > > > > > ===== > > Rahul S. Johari (Director) > > ****************************************** > > Abraxas Technologies Inc. > > Homepage : http://www.abraxastech.com > > Email : abraxastech@yahoo.com > > Tel : 91-4546512/4522124 > > ******************************************* > > > > __________________________________________________ > > Do You Yahoo!? > > Yahoo! Auctions - buy the things you want at great prices > > http://auctions.yahoo.com/ > > -- Mauricio Souza Lima Programador - Catho ONLINE mauricio@catho.com.br www.catho.com.br mauriciosl@yahoo.com.br

« previous php.general (#51726) next »