Http Authentication using PHP

Like this blog? Consider exploring one of our sponsored banner ads...

There are two easy ways to login to a page protected by htaccess using PHP. You need to have the username and password of course… Anyway, a good use for this is if you want to scrape a page behind an htaccess login, or if you need to do something progammatically behind htaccess password protection.

1) You can access the page as:

http://username:password@domain.com/folder/page.php

2) You can set an extra parameter in curl:

curl_setopt($ch, CURLOPT_USERPWD, "username:password");

About this entry