Hi I am trying to login to website using Curl php , then I need to redirect to other page and the user should be deleted, and this website is using self sign certificate so far I was able to log In but I am not sure what happen after, therefore the scenario is:
- Login to url 1 using token, password, name
- Redirect to `link2` (`link2` should do an action)
my code look like:
$sslCertificate = PATH to ssl certificate
$$cookie_file_path = PATH TO TXT FILE
$url = mylogin page
//login
curl_setopt($ch, CURLOPT_HTTPHEADER, array($Header ifno..etc));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
curl_setopt($ch,CURLOPT_SSLCERT , $sslCertificate);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $username , $passwrod,$token);
curl_exec($ch);
$html = curl_exec($ch);
print_r($html);
curl_close($ch);
Redirect to delete page (I am not sure if its the right way):
$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $url2todeleteUser );
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch2,CURLOPT_COOKIEFILE,$cookie_file_path);
curl_setopt($ch2, CURLOPT_COOKIE, "cookiename=0");
curl_setopt($ch2,CURLOPT_SSLCERT , $sslCertificate);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch2);
var_dump($html);
curl_close($ch2);
For login it works, but for redirect to the $url2todeleteUser
, I am not getting any response or error and there is no changes
- I am not sure if I am setting the session in the right way
- is there some previous experience with the same situation or some clear code with steps and details what I am doing wrong ?