Sign in to follow this  
Arek the Absolute

libcURL and HTTPS login

Recommended Posts

I'm currently trying to use libcURL to manage a couple simple tasks to communicate with Apache via HTTPS. What I'd like to do consists of two parts: Firstly, it needs to do a quick login with a username and password, and secondly, it needs to post a little more information to a second form once it's logged in. In code I can log in fine, and receive the page with the second form. However, when I try to post the data to the second form, I always receive the login page like I've never logged in at all, rather than a confirmation like I'd expect. I've used almost identical code with Windows specific libraries before without this problem, so it seems to me like I must be missing some characteristic of cURL somewhere along the lines. Does anyone have any suggestions that might help with this? A brief outline of the code: curl_easy_create() ... // login w/ username and password curl_easy_setopt(curl,CURLOPT_POSTFIELDS,postFields); curl_easy_perform(); // received the new form here // post form data curl_easy_setopt(curl,CURLOPT_POSTFIELDS,newFields); curl_easy_perform(); // receive the login page here. huh? curl_easy_cleanup(); I've tested the data that's being posted and I'm quite certain the data in postFields and newFields is as it should be. I can also say for sure that cookies aren't a part of the login process. Alternatively, if there are any suggestions for other libraries than cURL, they'd be greatly appreciated. The only requirement is that it must operate on Linux. Free is a bonus, but not a requirement.

Share this post


Link to post
Share on other sites
You need to figure out how the login service works. If it's HTTP authentication, then the authentication needs to be supplied in the request headers. If it's a site- or server-specific authentication system, then the authentication token is likely put in a cookie that you need to keep passing back.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this