curl-library
Re: A sample to login and maintain session
Date: Mon, 15 Jun 2009 14:45:45 -0400
2009/6/15 Aditya Kumar Gupta <adityagupta.18_at_gmail.com>:
> I have written an application in C and I am using it to login into a website
> and request a few details from it. The url is a website which uses web
> services and communicates in JSON format.
> Basically there are two operations where first being the login and second
> being the request for some data. Both the forms are on https and are part of
> a java service which communicates in JSON format. While I am able to login
> to the url and I get a success message as 200 OK. It also gives me a
> JSESSIONID. I have enabled the cookie engine by calling
> curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""). When I try to connect to
> the second url, and POST data to it, it redirects me to a new page stating
> that the access is unautorized. I am not sure how to send the JSESSIONID
> received from the first(/login) url to the second url. Can anyone please
> help me by writing a small example for the same.
From what I remember, the JSESSIONID is passed to the server by
appending it to the URL. Just add the following to all urls after you
have received the JSESSIONID:
;jsessionid=SESSION_IDENTIFIER
-Craig
Received on 2009-06-15