Reputation: 729
I have some issues getting a web page using CURL. I think the reason is that my CURL request does not include the JSESSIONID value.
This is how my cookie file looks like at the end:
direct.orange.co.il FALSE / FALSE 0 SMSESSIONMTySTv50SShcdl5y9C7TChWfGP5xbsW4P13QQLR6kkJyYtfVnx4q!574440962
bill4u.orange.co.il FALSE / FALSE 0 JSESSIONID 5rYLMT1QKTxTLhNTy0gkNGr4zGfhtlky9pxy20gHL1Ns65TgsCHy!-2121300565
Does it indicate some problems?
My CURL request only contains the SMSESSION value and not the JSESSIONID value.
This is thew request I got from live headers:
JSESSIONID=MTdLyyl2yGV1GnQW1LwlLQHPz0gPg8nCFpzDRkhQY01fLpTGGWnh!574440962; __utma=242473949.127100127.1288950781.1288950781.1288957650.2; __utmc=242473949; __utmz=242473949.1288957650.2.2.utmcsr=bill4u.orange.co.il|utmccn=(referral)|utmcmd=referral|utmcct=/action/mainAction; SMSESSION=mBRV8XSGka1o+98JnH7GpRLhljlhw7x4Gc2Y/2JWi6Yp277F0EzTLW09i1WTy00A5z2cfPcwLVjpQxrhTKINrQ6lfjyatS3EOGe6Nz7RBvCwWpUEYAwXTwn9MqE0N+YzWU5Nb5MVXAke3jmYiTx7jYUXmiP9/3rvLaWetrlWCbI3gvWb979JC9Ae1dVYYXu4h8Zpdeo8hOIZc+lbMJ/hadI2aa2GHeymjhNrhVKKtyOlQkCS6enHvaT9D0Az/0pYiHv2R0LFSdM8QTBn7oTzkbJWEpLQKHel51sDDrSpyiQPLPQ1l1QPONSeO8Ik1wvpg8Pq7RG+Y2NosL9XiuQQscKJjO1oBZJkNCQE3u1wORC7/uid1Ur0XYOWUgT1EEj4xM55+QQQtdgVSTJaIT4odf8mB0J7R5sA5FqTQdqhOZ6VZkyyQXqMPHIfxyjIlSwqAeGec9IIz+7T+0NTwH6IOCCHXs3O98iXuZhBLw9AfbgEpMlVIFYEEdHl/0gUjOwfsTA/qgzrdvDLvKsOcIggAXl9pOwTktTQwXwKOT3/15k7LtsvgbqTG+CUBlRD3z4rfXlDArOH/vNk/JhOFGAJABD3QnovjseS7kgnMUqnWGHq7ygLOOwbPWa8lOSkX0uNsnh1vYE0hEiHzrvRYHKbwJoJaziguD0P34lje24al6W7oT241BgMF4GPWDg5JZ4yqCEzVuU5B1i7nIXCtAAGQ4Okd/BWsF6gUQdQ9e0tOGAv7QVzvl+lZINRFN/8DfUfsDSEUXhCgMPt8UAt7b9R2W2a0Zn8c21VHdPRAgddX+hFnUcIyWtOfpHkB4gGsABE8R2nMaCzh+3PHUNCJ/8Ve6Rb7fcKct7w/ekeGx0gwwcFXdhXoPfMY0dsD4/C6Yb65Sm8wHMjg7NLUKzMn/G2+cXTI5IG7KPtHQjUIHK0vvtAZhgxi32jgKCzDNj4HZATapt0A7OCyquOeAEchPPa+zc7V+wNw0yUr3LG2K9cdSkiO08gSBLnrAkCcWZ/FfFbYFuc7TvNNfP+WBsux3FkhLJXrWJ1NqnC7de/BQlalXIcrngmRAgcWnLtyFCblujULgEqNbc5Vh8A22nu6Sy0AB1BOYlxXJ9J; __utmv=242473949.|1=VisitorsStatus=LoggedInClient=1,; __utmb=242473949.16.10.1288957650
And this is from the CURL request:
SMSESSION=SlMZENh5Y6AifK0BtPrGTy7MvVJpjcNX2qRAzNe7619KSGZwFf83Esx5Z3FHviWVSafX9XaeXOWc+eR1EGxLJXHv+KThakQX4X46zJnbZBs86Tk42SMXgUYe9R0XhmjMpHyeCsqcPqRuyBvelIW4V1Giof5SITSsWscY1QG9Rg+k67lASXQbk1nVCSn9S15In1vXGOlaKVuJMRpaTk4yf7HcYYHt+BSrPp8WYqPDZaNd1qaaRRuG0qe2jx+XsCobSq8xdyeFRXx7dvXHZdutH1RH8iCQFSvVgUKS80/Q2WEWtv12mxn1CRzRHsFalx7ohuwHbKYXWRKxEktxf/kXXpsDcpEx5NSLf820gPewqnymHuzNKFlsmCdcdSss0jE4aXZ44zedVcko1vx2m2Fo36/2WCae5zjzmkaWKJBwztqlWAl6HWFq1Ga8/IIUm+BRKJ7fUzvOrImImbDchKXFmB5Kbh2SfibaM1JZd2EjhnS1+D/1aMAitASJDSz4NihN53icSfzZ9agcbnr7vUCX6s9TxLiekjXxcOHQyzbrxH0CRQs+Ngq/Hxi4GtjCZgNpzUDWiDLTohaJmRVpNxta/e+uEjEphA578gqb1gdCIy8xnjpBw0dymAtLSb9Ypr+f5C4T4Q93H5vxRC9PZZpmlIcsbw+w3xfO+XWIgr5YFNP7mjovVNh4msOIdWWAHpjJML1GD1Ws/hwPfnO5qxEiUOdkbsozfsoGaHfp1gk4Vl/CTm37h3mbAnfT2W1yt1XTK3nGGD2YkjZbKhYL8PyoYCZDJaCFj8PixFyVcf43U9w/wAZDRznoy/yzvCsDy8FGKk1hTPSe9Fi8zcGnK86eQzLrK7wkcDKmyfxGyFZcoo3MfblnM4DCTlksYBlnIA+0GQtlf407zyMzXTIs01NeWOANUcl2IaXu1M3wiSIuCb1ocd8PUPNn2kgP5NT3yXB5qdzvkd/0tZVIuvA30ZY0jqfpwJxAgH99EBy3qCi+hO/1ipfVKtpAB31ArK5mN+Aapf6jx1+1LbLn9V5tzzppktkaGRLvTEOTBoEvguxwB163OMCw+Zjs7PGtVKSPsAHe2/kzp9STRPXn6tufhQvA9SwFLQdNWWhFBw6eqLsMoVVvFc1UV9IsjiLdpZddLR9t; JSESSIONID=MTySTv50SShcdl5y9C7TChWfGP5xbsW4P13QQLR6kkJyYtfVnx4q!574440962
Hope this helps.
EDIT: it seems that the JSESSIONID value is being generated on the fly when I hit the new url.
Upvotes: 3
Views: 20410
Reputation: 1
Thanks all. I did the following based on the messages above and it worked
curl --cookie-jar /tmp/storecookie.txt -X POST -H "Content-Type: application/json" -H "header2:value" -d '{"field1":"value1","field2":"value2"}' -k https://someurl.com
USE the Jsessionid from the /tmp/storecookie.txt and feed to the below
curl --cookie "JSESSIONID=34f0ef966c3b3a79bddbd1c406775716" -X GET -H "Content-Type: application/json" -H "header2:value" -o /tmp/response.txt -k https://someurl.com
Upvotes: 0
Reputation: 401
Try this syntax to get curl to pass the jsessionid cookie and place the fetched data in a textfile:
curl --cookie "JSESSIONID=5rYLMT1QKTxTLhNTy0gkNGr4zGfhtlky9pxy20gHL1Ns65TgsCHy!-2121300565; path=/" -o jj.txt "http://bill4u.orange.co.il"
Upvotes: 7
Reputation: 7257
Have you checked the curl documentation (see section 10 here)
Curl has a full blown cookie parsing engine built-in that comes to use if you want to reconnect to a server and use cookies that were stored from a previous connection (or handicrafted manually to fool the server into believing you had a previous connection). To use previously stored cookies, you run curl like:
curl --cookie stored_cookies_in_file http://www.cookiesite.com
Curl's "cookie engine" gets enabled when you use the --cookie option. If you only want curl to understand received cookies, use --cookie with a file that doesn't exist. Example, if you want to let curl understand cookies from a page and follow a location (and thus possibly send back cookies it received), you can invoke it like:
curl --cookie nada --location http://www.cookiesite.com
Curl has the ability to read and write cookie files that use the same file format that Netscape and Mozilla do. It is a convenient way to share cookies between browsers and automatic scripts. The --cookie (-b) switch automatically detects if a given file is such a cookie file and parses it, and by using the --cookie-jar (-c) option you'll make curl write a new cookie file at the end of an operation:
curl --cookie cookies.txt --cookie-jar newcookies.txt http://www.cookiesite.com
Upvotes: 7