Jump to content

Curl Login Not Working - WTF!


glenelkins

Recommended Posts

Hi

 

can anyone see why this code keeps returning the login page, like its not actually posting the form:

 

//init curl and login
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "https://members.cj.com/member/login" );
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7');
        curl_setopt ( $curl, CURLOPT_FAILONERROR, true );
        curl_setopt ( $curl, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );
        curl_setopt ( $curl, CURLOPT_CONNECTTIMEOUT, 10 );
        curl_setopt($curl, CURLOPT_TIMEOUT, 10);
        curl_setopt ($curl, CURLOPT_COOKIEJAR, "cj.txt");
        curl_setopt ($curl, CURLOPT_POST, 1);
        curl_setopt ($curl, CURLOPT_POSTFIELDS, "uname=email@domain.com&pw=blabla2727");
        
        
        $return = curl_exec($curl);
       
        
        
        // close curl
        curl_close ( $curl );
        
         die ($return);

Link to comment
Share on other sites

Well first you have to get the page to login right. (You dont submit data to the form, you submit data to the form processor).

/member/foundation/memberlogin.do

 

Then you have to mimmick _all_ of the fields...

curl_setopt ($curl, CURLOPT_POSTFIELDS, "uname=email@domain.com&pw=blabla2727&go=Go&nextpage=");

 

But notice when you login you have a "jsessionid". So you may need to "Grab" the Login form page first, then add the jsessionid key to the URL you are submitting the data too, example:

/member/foundation/memberlogin.do;jsessionid=abc4thPl7eUxtcKGjqQLs

 

-cb-

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.