I can login to a site with PHP cUrl, but I cannot navigate its pages. When I look at the cookie.txt file, login information appears, but when I want to access other pages, it seems like I'm not logged in. Why do you think it might? There are input data in cookie.txt, I show the relevant folder as the path, but I can't log in to other pages of the site.
<?php
require 'curl.php';
$base = "https://siteadi.com/login";
$html_base = file_get_html($base);
$token = $html_base->getElementByTagName("input[name=currentPageToken]")->getAttribute("value");
$agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36";
$data = array(
"username" => "*******",
"password" => "*******"
);
//init curl
$ch = curl_init();
//Set the URL to work with
curl_setopt($ch, CURLOPT_URL, $base);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
// ENABLE HTTP POST
curl_setopt($ch, CURLOPT_POST, true);
//Set the post parameters
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
//Handle cookies for the login
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
//Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
//not to print out the results of its query.
//Instead, it will return the results as a string return value
//from curl_exec() instead of the usual true/false.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute the request (the login)
$store = curl_exec($ch);
//the login is now done and you can continue to get the
//protected content.
//set the URL to the protected file
curl_setopt($ch, CURLOPT_URL, 'https://siteadi.com/profil');
//execute the request
echo $content = curl_exec($ch);
curl_close($ch);
I can login, information comes to cookie.txt. However, when I switch to other pages of the site, it is perceived as if I am not logged in.
//The code block I tried is as follows
$ch = curl_init();
//the login is now done and you can continue to get the
//protected content.
//set the URL to the protected file
curl_setopt($ch, CURLOPT_URL, 'https://siteadi.com/profil');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//execute the request
echo $content = curl_exec($ch);
curl_close($ch);