Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Separate CookieJar objects for WebPages #11417
Currently, there exists a single CookieJar object for all web pages. This is in line with the usual behaviour of web pages, but causes difficulty when treating pages as separate entities.
To fix: CookieJar should not be a singleton, and objects that use a CookieJar should have one passed in on construction.
Ok. I think the code would look like this:
var myJar = new CookieJar(); page1.cookieJar = myJar; page2.cookieJar = myJar; myJar.addCookie(cookie); ... do whatever ... page1.close(); page2.close(); myJar.save(path); myJar.close();
A new page would have the default CookieJar and then you can set the page's CookieJar to be whatever you want.
Also, I think that the CookieJar should have the same API that both the phantom and webpage objects have with cookies.
addCookie(Cookie); deleteCookie(cookieName); cookies; clearCookies(); save(path); close();
We should also add a CookieJar getter on the phantom object and both a getter and a setter for the CookieJar in webpages.