Browsing articles tagged with " CURL"

Maintaining PHP session when using CURL.

Working now on some iGoogle like dashboard for the system I’m developing.

I was trying some stuff out with CURL and was having a hard time to maintain my current session when making a curl request to another page. I needed to stay authenticated in order to retrieve my widget.

Here is my initial code:

$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';     
$ch = curl_init($rssFeedLink); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt( $ch, CURLOPT_COOKIE, $strCookie ); 
$response = curl_exec($ch); 

The problem with that piece of code is that it was generating a new session id instead of sending my current session.

The solution? read more