Sample Header Ad - 728x90

Difference between cURL's cookie-jar option and browser cookie?

2 votes
1 answer
2696 views
I'm trying to login to a website using curl and HTTP requests. With the first http GET request I add -c cookie.txt to the command to save the cookie to a file. For the second curl POST I add -b cookie.txt to pass the same cookie again. Unfortunately I end up with a wrong session error message. When I compare the POST request with Chrome's POST request I see that the cookie has more data than what's in my cookie.txt. When I copy Chrome's POST using "copy as cURL command" I get for the cookie: -H 'Cookie: PHPSESSID=rrh5d7l69tgl8633g3hklea2e0; POPUPCHECK=1140804027760' But my cookie.txt only contains the PHPSESSID. What am I not seeing here? Thank you! **Edit** I added the verbosity flag to the two commands and received this output: curl -v https://my.host.com --cookie-jar cookie.txt GET / HTTP/1.1 > Host: my.host.com > User-Agent: curl/7.54.0 > Accept: */* > POST / HTTP/1.1 > Host: my.host.com > User-Agent: curl/7.54.0 > Accept: */* > Content-Type: application/x-www-form-urlencoded > Content-Length: 73 > * upload completely sent off: 73 out of 73 bytes < HTTP/1.1 200 OK < Date: Tue, 30 Oct 2018 09:39:06 GMT < Server: Apache/2.2.22 (Debian) * Added cookie PHPSESSID="lg9h4h8hlk69lrkosn0abpg7n7" for domain my.host.com, path /, expire 0 < Set-Cookie: PHPSESSID=lg9h4h8hlk69lrkosn0abpg7n7; path=/ < Expires: Thu, 19 Nov 1981 08:52:00 GMT < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 < Pragma: no-cache * Replaced cookie PHPSESSID="r33haq0v45r4ofksrmm2ok86c5" for domain my.host.com, path /, expire 0 < Set-Cookie: PHPSESSID=r33haq0v45r4ofksrmm2ok86c5; path=/ < Vary: Accept-Encoding < Content-Length: 3792 < Connection: close < Content-Type: text/html; charset=utf-8
Asked by tzippy (381 rep)
Oct 29, 2018, 03:35 PM
Last activity: Sep 27, 2020, 05:00 PM