I am connecting to an API service which authenticates users using cookies. I make these two statements from command prompt and it works.
curl -d "u=username&p=password" -c ~/cookiejar https://domain/login
curl -b https://domain/getData
Now I want to make two equivalent php files login.php and get_data.php using curl.
I am using
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
in login.php
and
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
in get_data.php
It is not working. Cookie file is getting created but second curl is not reading it.
Is this the right way to do it ? Do I have to read the cookie file seperately and set the header Cookie ? Any help would appreciated. Thanks.
Cookiebe automatically added to curl request inget_data.php?