Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8386599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:59:06+00:00 2026-06-09T17:59:06+00:00

I try to login with curl to a SSL secured website but somehow I

  • 0

I try to login with curl to a SSL secured website but somehow I don’t get it right.

The first curl connection retrieves the login form. An SSL issue in the beginning is resolved now. The fields used for authentication and all hidden fields are identified and used for the following POST. The cookie file is defined and the jar to read from as well. The cookie file is accessible and gets updated with each login attempt. A session cookie is successfully set by curl. The HTTPHEADER is removed to stop the request from hitting the 100 Continue wall. Curl is configured to follow up and to send a referer.
However, I still cannot find where the script gets stuck. Neither Curl nor PHP issue any error messages or warnings.

Here is the shortened script:

$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE,       1);
curl_setopt($ch, CURLOPT_HEADER,        1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_AUTOREFERER,   1);
curl_setopt($ch, CURLOPT_HTTPHEADER,    array('Expect:')); // remove Expect header to avoid 100 Continue situations
curl_setopt($ch, CURLOPT_USERAGENT,     'Mozilla [abbreviated]');
curl_setopt($ch, CURLOPT_CAINFO,        dirname(__FILE__).'/cacert.pem');
curl_setopt($ch, CURLOPT_COOKIEFILE,    dirname(__FILE__).'/cookie.hq.txt'); // write cookies
curl_setopt($ch, CURLOPT_COOKIEJAR,     dirname(__FILE__).'/cookie.hq.txt'); // read cookies
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_URL,           'https://the_url.jsp');

$data = curl_exec($ch);
$error= curl_error($ch);
if(!empty($error))
    echo '<p>'.$error.'</p>';
else
    echo '<p>ok</p>';

Now the script reads the form, fills in the credentials and POSTs it back using the same curl_init handle:

curl_setopt($ch, CURLOPT_POST,       1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $options);
$data = curl_exec($ch);
$error=curl_error($ch);

But all I get back is the same form again and the same session cookie or a new one depending on the CURLOPT_COOKIESESSION setting.

When I log in manually I notice that there are two more cookies set: LtpaToken and LtpaToken2 but I never see them appearing in the request headers printed by the script.
Manually submitting the form works even without Javascript aktivated. So there cannot be some JS magic modifying the form data under the hood before submitting it.
Obviously I am missing something here. Any ideas where I can look further?

Solved: Finally the issue was due to an encoding issue in the POST.
Initially the POST data was created from an array with http_build_query().
Now the POST data is simply concatenated and both keys and values are urlencoded separately:

    $options.=urlencode($fieldName).'='.urlencode($element->getAttribute('value'));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:59:07+00:00Added an answer on June 9, 2026 at 5:59 pm

    Solved: Finally the issue was due to an encoding issue in the POST. Initially the POST data was created from an array with http_build_query(). Now the POST data is simply concatenated and both keys and values are urlencoded separately:

    $options.=urlencode($fieldName).'='.urlencode($element->getAttribute('value'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a login for a website using PHP but when I try to
I try to provide a login with the facebook-php-sdk. But, when I click on
I've been trying to override the file login.xml but no matter what I try,
So I have my login form in my website. And for example my username
HI, I am able to login into the site using php and curl. but
i try to login into a forum with c# webclient to get userrelevant informations
I'm trying to create a 'remote login' site, but when I try the below
When I try to login to our WSS demo site the authentication popup forces
When try to access site i created after 3 login attempts it gives unauthorised
I cannot login using email in CakePHP 2.1, when i try with username then

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.