Im using MAMP on a Mac running OS X Lion.
I need to connect to a remote site sending the cookie.
All goes well except for the cookie part.
For the cookie part I’m using this code:
$cookieFile = dirname(__FILE__).'/cookie.txt';
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);
The CURLOPT_COOKIEJAR part does create a cookie, but on a subsequent request CURLOPT_COOKIEFILE doesn’t add a cookie header. I’ve checked this using HTTPScoop (a Fiddler like tool).
Any idea what might be the problem?
EDIT:
Im connecting to a ASP.Net site. Problem seems to be the im not getting a ASP.NET_SessionId cookie. The cookie i do get has a key without a value, thats probably the reason why it isn’t posted.
Any idea how to force the server to send a session cookie?
We’d really need to see more code, but here is a sample bit I have which collects a session cookie from an initial request then uses it in a subsequent POST. It uses an anonymous proxy to run a GET request on an arbitrary URL, hopefully it helps you (to be clear though it doesn’t use the COOKIEJAR, but I feel it may still be helpful).