cURL / Mailing Lists / curl-and-php / Single Mail


Re: help with curl POST with cookie

From: Tomas <>
Date: Tue, 26 Feb 2008 04:33:23 -0800 (PST)

If I set CURLOPT_VERBOSE here's what I get on the output...

* About to connect() to port 80includes/curl_ryanair_dev.php
* Trying * connected
* Connected to ( port 80
> POST /SkySales/FRSearchRedirect.aspx HTTP/1.1
Accept: */*
Content-Length: 264
Content-Type: application/x-www-form-urlencoded
travel_type=on&sector1_o=aSTN&sector1_d=KUN&sector_1_d=27&sector_1_m=042008&sector_2_d=00&sector_2_m=--&ADULT=1&CHILD=0&INFANT=0&mode=0&pT=1ADULT&oP=&rP=&nom=1&date1=20080427&date2=&m1=20080427aSTNKUN&m2=&m1DP=0&m1DO=0&m2DP=0&m2DO=0&pM=0&tc=1&module=SB&page=SELECT< HTTP/1.1 302 Found
< nnCoection: close
< Date: Tue, 26 Feb 2008 12:29:25 GMT
< Server: Microsoft-IIS/6.0
< X-Powered-By: ASP.NET
< X-AspNet-Version: 2.0.50727
< Pragma: no-cache
< Pragma: no-cache
< Location:
< Set-Cookie: ASP.NET_SessionId=regfbtd4z045on1gjcjsvbfo4gmo; path=/; HttpOnly
< Cache-Control: no-cache, no-store
< Pragma: no-cache
< Expires: -1
< Content-Type: text/html; charset=utf-8
< Content-Length: 166
* Connection #0 to host left intact
* Closing connection #0
<html><head><title>Object moved</title></head><body>
<h2>Object moved to here.</h2>

----- Original Message ----
From: Tomas <>
Sent: Tuesday, February 26, 2008 12:06:41 PM
Subject: help with curl POST with cookie

I need some ideas from you please!
The website I used to check cheap flights have changed their booking system from cgi based to aspx, and with that it is not just a simple POST query, it appears I need to have a "cookie".
Data caputred with wireshark while trying to book a flight:
Hypertext Transfer Protocol
 POST /SkySales/FRSearchRedirect.aspx?culture=EN-GB HTTP/1.1
  Request Method: POST
  Request URI: /SkySales/FRSearchRedirect.aspx?culture=EN-GB
  Request Version: HTTP/1.1
 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/, application/, application/msword, */*
 Accept-Language: en-gb
 Content-Type: application/x-www-form-urlencoded
 Accept-Encoding: gzip, deflate
 User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
 Content-Length: 264
 Connection: Keep-Alive
 Cache-Control: no-cache
 Cookie: WT_FPC=id=; ASP.NET_SessionId=regfu04fe332nuihir45bc2tyi45
Line-based text data: application/x-www-form-urlencoded
I tried simply POST Line-based text data: application/x-www-form-urlencoded content to
function curl_ryanair()
$ch = curl_init();
/* curl set options */
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "travel_type=on&sector1_o=aSTN&sector1_d=KUN&sector_1_d=27&sector_1_m=042008&sector_2_d=00&sector_2_m=--&ADULT=1&CHILD=0&INFANT=0&mode=0&pT=1ADULT&oP=&rP=&nom=1&date1=20080427&date2=&m1=20080427aSTNKUN&m2=&m1DP=0&m1DO=0&m2DP=0&m2DO=0&pM=0&tc=1&module=SB&page=SELECT"
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
/* exec curl */
$data = curl_exec ($ch);
/* end curl session */
return $data;

but I'm getting a message saying
Object moved to here.
How do I need to fix the script so when I do POST I'm actually posting with that cookie?

Looking for last minute shopping deals? Find them fast with Yahoo! Search.

Looking for last minute shopping deals?
Find them fast with Yahoo! Search.

Received on 2008-02-26