I'm trying to display the contents of a page after logging into the system.
The login is successful, I receive the welcome from the system, however when I change the URL and make a new curl_exec
I get http_code = 302
, but accessing via the browser normally exists.
$username = $_GET['username'];
$password = $_GET['password'];
$data = array('josso_cmd' => 'login', 'josso_username' => $username, 'josso_password' => $password);
$url = "...";
$referer = "...";
$user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36";
$url_notas = "...";
$referer_notas = "...";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__). '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
print_r(curl_exec($ch));
print_r(curl_errno($ch));
print_r(curl_getinfo($ch));
echo "<hr>";
curl_setopt($ch, CURLOPT_URL, $url_notas);
curl_setopt($ch, CURLOPT_REFERER, $referer_notas);
curl_setopt($ch, CURLOPT_POST, 0);
print_r(curl_exec($ch));
print_r(curl_errno($ch));
print_r(curl_getinfo($ch));
The return is:
HTTP / 1.1 302 Moved Temporarily
It returns me to the login URL, as if it had lost section.
My question is Where am I going wrong?