We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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) . '" />';`
The text was updated successfully, but these errors were encountered:
after setting all the cookies, try doing another getCookies() and compare the saved array to the one you set. like this:
$savedCookies = unserialize(file_get_contents(DIR . '/tmp/cookies/cookies.ser')); foreach($savedCookies as $key=>$value){ //... your logic } $newCookies = $windowObj->getCookies();
//then compare the saved to the current var_dump($savedCookies); var_dump($newCookies);
Chances are the domain attribute is wrong for one of more cookies (see this issue )
#18
Sorry, something went wrong.
merlinthemagic
No branches or pull requests
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');
The text was updated successfully, but these errors were encountered: