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 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, cookies are used on every request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.