cURL / Mailing Lists / curl-users / Single Mail

curl-users

how to get redirect cookie with curl

From: Guirong Wang <guirong2004_at_yahoo.com>
Date: Tue, 5 Jun 2007 16:56:36 -0700 (PDT)

 
  Hi, all
I am working on a web site for uploading files with curl. When I log in from the web browser, there is a APC_REDIR value in
  the LiveHTTPHeaders as shown in the following:
  ********************************************************************************************
  https://somesite.com/login
  ..
..
..
..
  
HTTP/1.x 200 OK
..
..
..
  ----------------------------------------------------------
https://www.anothersite.com/land.aspx?type=ohp
..
 
Cookie:
  APC_REDIR=PD94bWwgdmVyc2lvbj0iMS4wIj8+DQo8YXV0aGVudGljYXRvcj4NCiAgPHJlZGlyPmh0dHA6Ly9zdC5jb25uZWN0aXZhLmNvbS88L3JlZGlyPg0KICA
  8Y29va2llZG9tYWluPi5jb25uZWN0aXZhLmNvbTwvY29va2llZG9tYWluPg0KPC9hdXRoZW50aWNhdG9yPg==; wwwcsticky=2215201223.20480.0000;
  ASPSESSIONIDCQQCDCTQ=NEPMBGCCKEFHFKAKIDMNPICP; ASP.NET_SessionId=wf5fzb55yjxm3d31yc14gh45
 
  HTTP/1.x 302 Found
Set-Cookie: wwwcsticky=2215201223.20480.0000; expires=Tue, 05-Jun-2007 20:37:22 GMT; ..
..
..
  ----------------------------------------------------------
https://anothersite.com/path=XXXXXXX
..
..
..
  Cookie:
  APC_REDIR=PD94bWwgdmVyc2lvbj0iMS4wIj8+DQo8YXV0aGVudGljYXRvcj4NCiAgPHJlZGlyPmh0dHA6Ly9zdC5jb25uZWN0aXZhLmNvbS88L3JlZGlyPg0KICA
  8Y29va2llZG9tYWluPi5jb25uZWN0aXZhLmNvbTwvY29va2llZG9tYWluPg0KPC9hdXRoZW50aWNhdG9yPg==; wwwcsticky=2215201223.20480.0000;
  ASPSESSIONIDCQQCDCTQ=NEPMBGCCKEFHFKAKIDMNPICP; ASP.NET_SessionId=wf5fzb55yjxm3d31yc14gh45
  HTTP/1.x 200 OK
..
..
..
  
*******************************************************************************************
  but When I tried to log in with the following curl command:
  curl -L -D header.txt -d "user=user&pass=pass..." https://somesite.com/login; curl -L -b header.txt -c cookies.txt
  "https://anothersite.com/land.aspx?type=ohp"
The header.txt file is good but the cookies.txt file content is:
  *******************************************************************************************
# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
  unknown FALSE /cgi-bin FALSE 0 OHPAuth MIIEGwYJKoZIhvcNAQcDoIIE
DDCCBAgCAQAxggEAMIH9AgEAMGYwXjESMBAGA1UEChMJYmVUUlVTVGVkMRYwFAYDVQQLEw1iZVRSVVNU
ZWQgQ0FzMTAwLgYDVQQDEydiZVRSVVNUZWQgQ0EgLSBCYWx0aW1vcmUgSW1wbGVtZW50YXRpb24CBD8L
FCEwDQYJKoZIhvcNAQEBBQAEgYAGJ53c5UIe1xkb7iqsZyChyEe2VaCpS3LjWNE89Rjp6RWCbsrqGqwr
vPcz5qpfYvnF8IxSVJnb2eEUupC7NjmlPxKZqvr9cdgmb5t9VIOJqqzJBqRWN0tuelA+THGvi+8oroBz
...=
www.anothersite.com FALSE / FALSE 1181092093 wwwcsticky
2215201223.20480.0000
www.anothersite.com FALSE / FALSE 0 ASP.NET_SessionId
ljajd4552vsjyv55sbqh4h55
  ********************************************************************************************
If I replace -c with -D as following:
curl -L -D header.txt -d "user=user&pass=pass..." https://somesite.com/login; curl -L -b header.txt -D cookies.txt
  "https://anothersite.com/land.aspx?type=ohp"
the cookies.txt contains the following:
  ********************************************************************************************
HTTP/1.1 302 Found
Set-Cookie: wwwcsticky=2215201223.20480.0000; expires=Wed, 06-Jun-2007 01:12:51
GMT; path=/
Date: Tue, 05 Jun 2007 23:12:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Location: new location
Set-Cookie: ASP.NET_SessionId=oumbqfi3ccysvx20zjre5d45; path=/
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 1123
  HTTP/1.1 200 OK
Set-Cookie: wwwcsticky=2215201223.20480.0000; expires=Wed, 06-Jun-2007 01:12:51
GMT; path=/
Date: Tue, 05 Jun 2007 23:12:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Length: 7622
*********************************************************************************************
There is still no redirect cookie (APC_REDIR=...) information here, so when I tried to continue to the next page, I got the
  "no redirect cookie found" error message. Any idea?
  (I am using curl 7.12.1 on Linux.)
  Thanks in advance.
  
 

       
---------------------------------
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
Received on 2007-06-06