Reputation: 5087
Let's say I have a domain foo.com
and it has a page called foo.com/bar.php
In one of the functions in the site, I try accessing foo.com/bar.php
via cURL.
However, some stuff in foo.com/bar.php
is dependent on the current session.
Hence, I want to retain the current session of the calling method into the cURL method.
Is there a way to do this?
Upvotes: 1
Views: 65
Reputation: 388
You have to setup some additional curl options:
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
With above settings the cookies will be stored in cookie.txt :)
Upvotes: 1