Curl not passing phpsessid

Try as I could, I can’t get curl to pass cookie PHPSESSID. I have a similar setup, which some others talked about, but I could not get any of the proposed solutions.

I have a page that sends a request for receipt pageA.php. pageA.phpsome information is required from pageB.phpthat is on another server, so I use curl. pageBmaintains the session state that I need to get from my page.

I can transfer other cookies with pageAbefore pageBand not in cookies PHPSESSID.

The following works (cookie comes on pageB):
  $options[CURLOPT_COOKIE] = "myPHPSESSID=" . $sessionId;

It is impossible:

$options[CURLOPT_COOKIE] =  "PHPSESSID=" . $sessionId;

(I create an array of $ options and pass it curl_set_opt_array)

In fact, the latter causes some error that I cannot recognize, since my call curl_execnever returns (and pageBnever reaches).

I tried to set the header instead of using CURLOPT_COOKIE, but also without success:

$options[CURLOPT_HTTPHEADER][] = "Cookie: myPHPSESSID=" . $sessionId;

above works fine but

$options[CURLOPT_HTTPHEADER][] = "Cookie: PHPSESSID=" . $sessionId;

no.

PHP clearly does not want me to manually set PHPSESSID. I am not sure if this is appropriate, but by no means on the page. I call start_session()(although I tried to do this and had the same results).

, () cookie pageB call set_session_id() - . , , , , , , . , pinging around, , , .

...

+5
1

. .

session_write_close(); curl_exec.

: http://kmak.1funkybit.com/?p=126 ( ).

:

<?php
session_start();
var_dump($_SESSION); //See what in session
echo "<br>";



$c = curl_init('http://192.168.100.204/logintest/index.php?r=AccessTest/CheckAcess');
$parametros_post = 'action=verChau';
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $parametros_post);
curl_setopt($c, CURLOPT_VERBOSE, TRUE);
curl_setopt($c, CURLOPT_COOKIE, 'PHPSESSID=' . $_COOKIE['PHPSESSID']);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
session_write_close();
$page = curl_exec ($c);
echo "<br>";
echo "<br>";
echo $page;
curl_close ($c);


?>
+8

All Articles