You are here: Re: What is the purpose of the 401 Header in this PHP Manual Example? « PHP Programming Language « IT news, forums, messages
Re: What is the purpose of the 401 Header in this PHP Manual Example?

Posted by peter on 07/01/07 21:53

>I can remove the 401 header line in the following code and it operates
> exactly the same.
>
> <?php
>
> if (!isset($_SERVER['PHP_AUTH_USER'])) {
> //header('WWW-Authenticate: Basic realm="My Realm"');
> header('HTTP/1.0 401 Unauthorized');
> echo 'Text to send if user hits Cancel button';
> exit;
> } else {
> echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
> echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</
> p>";
> }
> ?>

A 401 header is a standard header that informs the browser/user that they
are not authorised to access the requested page. As you can see from the
script it is triggered in this case if $_SERVER['PHP_AUTH_USER'] is not set
ghence the user not logged in.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация