<?php
$mypath = getcwd();
$mypath = preg_replace('/\\\\/', '/', $mypath);
$rand = rand(1, 15000);
$cookie_file_path = "$mypath/cookies/cookie$rand.txt";
$data = array(
'username' => 'softnas',
'password' => 'Pass4W0rd'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://example.com/softnas/login.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path); // Cookie management.
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file_path);
curl_setopt($ch, CURLOPT_COOKIESESSION, TRUE);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
echo $info;
|