Hi all, Is it possible the login by posting username and password from any other php application (using curl) to Yii application?
How set the login url?
This is the code i’m used for login
<?php
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8888/yiiapp/site/login');
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user_mailid=yiiuser***@gmail.com&user_password=yii*****@');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
print_r($store);
curl_setopt($ch, CURLOPT_URL, 'http://localhost:8888/yiiapp/');
$content = curl_exec ($ch);
print_r($content);
// CLOSE CURL
curl_close ($ch);
?>
Thanks.