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

curl-and-php

libcurl and curl COOKIE help.

From: shawn a <boris317_at_gmail.com>
Date: Thu, 15 Dec 2005 16:16:09 -0500

Hello,
First time poster here. Ok so this is my problem.

Im working on an application that requires using curl to log into a
session. Ive done this using
this command line curl command:(url and params changed for security reasons)

curl -d "password=something&userId=123" -D login.headers -c
login.cookies -b login.cookies -L -k -o login.html
https://someurl.com/login.do

as you can see im gathering the cookies and then using that same file
to send those cookies back to the server. This works fine and dandy. i
get the session i need and am able to use another curl request to get
some other data i need.

My cocern is when i try to translate this command into php using the
libcurl library. Im pretty sure the problem is in how im trying to
send the cookies back. This is what i have come up with:

      $cookie = randomfilename;
      $postdata = "password=something&userId=123"

        $cURL = curl_init(https://'someurl/login.do');
        curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($cURL, CURLOPT_COOKIEJAR, '/tmp/' . $cookie . '.cky' );
        curl_setopt($cURL, CURLOPT_COOKIEFILE, '/tmp/' . $cookie . '.cky' ); <--bug??
        curl_setopt($cURL, CURLOPT_POST, 1);
        curl_setopt($cURL, CURLOPT_POSTFIELDS, $postdata);
        curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, 0);
        $dump = curl_exec($cURL);
        
        unset($dump);
        curl_close($cURL)

I dont want any ouput to the screen hence the $dump variable catching
it(better way to do that?).

This method i have worked out here does not give me the desired
results. I get a response back from the server saying my cookies are
disable. Which leads me to believe im not sending those cookies back
correctly.

Any input would be great. THANKS!!

--shawn

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-12-16