Is it possible to set session variable on php site for example B.com by calling CURL request from another php site for example A.com?
Here is a code, which sending post request from A.com to site B.com/extAuth.php
<?php
session_start();
$url = 'http://B.com/extAuth.php';
$params = array(
'login' => 'login',
'pwd' => 'pass'
);
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => $params,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_COOKIESESSION => true,
CURLOPT_COOKIEJAR => 'cookie.txt',
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);
?>
Script on extAuth.php just set a SESSION['login'] = true. But when i open site B.com after sending this request from CURL, SESSION['login'] is undefined.
<?php
session_start();
if(isset($_POST['login'])&&($_POST['pwd'])){
//aditionall logic here
$_SESSION['login'] = true;
}
?>
But when i try send this request by ordinary html form placed on A.com site, SESSION variable is set. Here is code of form placed on A.com site.
<form action="http:B.com/extAuth.php" method="POST">
<input type="text" name="login" id="login" value=""></td>
<input type="password" autocomplete="off" name="pwd" id="pwd" value="">
<input class="btn" id="btn_login" value="Login" type="submit">
</form>
Anybody know what i am doing wrong?