php - Call other Domain/Server to get a cookies value -
we have 2 domains( xxx-source.com
, xxx-client.com
)
in xxx-source.com
, have cookies save there.
in xxx-client.com
, need check if cookies exist on xxx-source.com
.
i tried several methods no success.
========= method 1 ========= :
xxx-client.com:
file_get_contents( 'http://xxx-source.com/checkcokie.php' );
xxx-source.com/checkcokie.php:
if ( isset( $_cookie["some-name"] ) ) { echo $_cookie["some-name"]; } else { echo "not cookie found"; }
i'm getting "not cookie found". kinda understand why getting since getting file server , no users browser factor.
========= method 2 ========= :
i found here in on similar post not solved proble,
/* step 1. let’s create cookie file */ $ckfile = tempnam ("/tmp", "curlcookie"); /* step 2. visit homepage set cookie */ $ch = curl_init ("http://somedomain.com/"); curl_setopt ($ch, curlopt_cookiejar, $ckfile); curl_setopt ($ch, curlopt_returntransfer, true); $output = curl_exec ($ch); /* step 3. visit cookiepage.php */ $ch = curl_init ("http://somedomain.com/cookiepage.php"); curl_setopt ($ch, curlopt_cookiefile, $ckfile); curl_setopt ($ch, curlopt_returntransfer, true); $output = curl_exec ($ch);
=======
what best approach problem? thanks.
Comments
Post a Comment