It's always good to study the topic at least basically, before (instead?) asking such questions:
http://www.php.net/manual/en/features.http-auth.php[
^],
http://www.homeandlearn.co.uk/php/php14p1.html[
^],
https://github.com/PHPAuth/PHPAuth[
^].
Besides, I'm not sure if you want to have your own password-based authentication, or want to authenticate the user through a third-party identity, as with as with OpenID, so consider this approach, too, or, even better, combine it with your own authentication, like many sites do. Please see:
https://en.wikipedia.org/wiki/OpenID[
^],
http://openid.net/[
^],
http://openidexplained.com/[
^].
Then you can use, for example,
https://github.com/openid/php-openid[
^].
—SA