Re: HTTP authentication : logout!!!

From: Date: Mon, 07 May 2001 23:07:35 +0000
Subject: Re: HTTP authentication : logout!!!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51723@lists.php.net to get a copy of this message
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/ > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#51723) next »