Setting PHP session variable on website by calling request from another site -
is possible set session variable on php site example b.com calling curl request php site example a.com?
here code, sending post request a.com 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 set session['login'] = true. when open site b.com after sending request curl, session['login'] undefined.
<?php session_start(); if(isset($_post['login'])&&($_post['pwd'])){ //aditionall logic here $_session['login'] = true; } ?>
but when try send request ordinary html form placed on a.com site, session variable set. here 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 doing wrong?
Comments
Post a Comment