Not Able Login Using Curl In My Yii Site

I have created one website using yii then tried create session using CURL but it is not working. I used following code:

<?php

&#036;cSession = curl_init();


&#036;username=&quot;admin&quot;;


&#036;password='mypassword';





&#036;url = &quot;localhost/mysite/&quot;;


&#036;ch = curl_init();


curl_setopt(&#036;ch, CURLOPT_URL, &#036;url);


curl_setopt(&#036;ch, CURLOPT_USERPWD, &quot;&#036;username:&#036;password&quot;);


curl_setopt(&#036;ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);


curl_setopt(&#036;ch, CURLOPT_RETURNTRANSFER, 1); 


&#036;output = curl_exec(&#036;ch); 


echo &#036;output;


curl_close(&#036;ch);





//echo &#036;result;

?>

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()

{

return array(


    array(


        'HttpAuthFilter',


    )


    


);

}

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.