Reading cookies
Each cookie that a web page generates or creates will be stored in the phantom.cookies
object.
To retrieve all the cookies, we access the cookies
member. Let us print the cookies
object:
page.open(url, function(status) { if ( status === "success" ) { console.log(phantom.cookies); phantom.exit(0); } });
If there are cookies in the website that we are accessing, then you should see output similar to the following screenshot:
Based on the preceding output, .yahoo.com has several cookies. These cookies vary on the website or URL. Each cookie is in object form, which can be viewed as a JSON object. Each cookie object will have the following properties:
{ 'name' : 'name of cookie', 'value' : 'value associated', 'domain' : 'cookie domain', 'path' : 'cookie path', 'httponly': (true or false), 'secure' : (true or false), 'expires&apos...