tags:

views:

170

answers:

1

I have a problem logging onto a page and then using it with cURL. I login, get PHPSESSID and cookie, and then try to do an action but page returns 'not logged in'. But if I manually log in and copy/paste that PHPSESSID into curl cookies .txt file, everything works fine. So why doesn't it work with PHPSESSID from cURL?

EDIT: It also works when I copy PHPSESSID generated by cURL to browser PHPSESSID, very strange.

EDIT 2: Found a problem, there was another logged in check not visible before.

+1  A: 

Do you point CURL to use cookies file on every request? Something like this:

  curl_setopt($c, CURLOPT_COOKIEFILE, '/tmp/cookies');
  curl_setopt($c, CURLOPT_COOKIEJAR, '/tmp/cookies');

This would tell CURL to save and load cookies from the file. COOKIEJAR tells where curl to save cookies after finishing request and COOKIEFILE tells it to load cookies from this file before request. Usually you would want the same file. More info on: http://php.net/manual/en/function.curl-setopt.php

bisko
Yes, cookies are used on every request.
dfilkovi
Found a problem.
dfilkovi