So i am trying to save the login state , by getting the cookie and saving it ;
$cookieArray = $windowObj->getCookies(); file_put_contents(__DIR__ .'/tmp/cookies/cookies.ser', serialize($cookieArray));

and then on the next script run, load that cookie file again , loop over it , but the login page still shows , here is my code;
`//open the login page:
$myUrl = "https://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&ref_=myab_view_new_address_form&viewID=newAddress";
$browserObj = \MTS\Factories::getDevices()->getLocalHost()->getBrowser('phantomjs');
$windowObj = $browserObj->getNewWindow();
$agentName = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36 OPR/46.0.2597.57";
$windowObj->setUserAgent($agentName);
$windowObj->setUrl($myUrl);
//read array
$cookieArray = unserialize(file_get_contents(__DIR__ . '/tmp/cookies/cookies.ser'));
foreach($cookieArray as $key=>$value){
/* echo "<pre>";
var_dump($cookieArray[$key]);
echo "</pre>"; */
$name = $cookieArray[$key]['name']; //String: mandetory cookie name.
$value = $cookieArray[$key]['value']; //String: mandetory cookie value.
$domain = $cookieArray[$key]['domain']; //String: defaults to current domain in window URL
$path = $cookieArray[$key]['path']; //String: defaults to "/";
$expireTime = $cookieArray[$key]['expiry']; //Int (epoch): default is 2147483647
$serverOnly = false; //Bool: default false; if true cookie cannot be read by client scripts.
$secureOnly = false; //Bool: default false; if true cookie can only be transmitted using secure (defined by the user agent, i.e. TLS) channel.
$windowObj->setCookie($name, $value, $domain, $path, $expireTime, $serverOnly, $secureOnly);
}
//perform a screenshot:
$screenshotData = $windowObj->screenshot();
//render it:
echo '<img src="data:image/png;base64,' . base64_encode($screenshotData) . '" />';`
So i am trying to save the login state , by getting the cookie and saving it ;
$cookieArray = $windowObj->getCookies(); file_put_contents(__DIR__ .'/tmp/cookies/cookies.ser', serialize($cookieArray));and then on the next script run, load that cookie file again , loop over it , but the login page still shows , here is my code;
`//open the login page:
$myUrl = "https://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&ref_=myab_view_new_address_form&viewID=newAddress";
$browserObj = \MTS\Factories::getDevices()->getLocalHost()->getBrowser('phantomjs');