I have created one website using yii then tried create session using CURL but it is not working. I used following code:
$cSession = curl_init();
$url = "localhost/mysite/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
Please help me…
Vanilla Yii doesn’t respect HTTP auth headers. You either need to install a filter that does or let cURL send a valid session cookie among the request.
Thanks Sourcerer for the guidance. I have downladed the php file and copied in component folder. Added following code to sitecontroller
public function filters()
Now, I am able to find myself logged in. But echoed out page is not showing the default page but error 401.
That’s puzzling. You should only get a 401 if you’re not logged in or the given login credentials were incorrect.