slimerjs icon indicating copy to clipboard operation
slimerjs copied to clipboard

Separated cookie jars by implementing webpage.cookieJar

Open prawnsalad opened this issue 11 years ago • 8 comments

Is it possible to have separated cookie jars for each created page?

I have a script that tests different scenarios on a webpage, logging in/out/taking actions/etc but they currently all share the same cookies making it impossible. I'm trying not to have several sublimejs instances open.

prawnsalad avatar Mar 10 '15 18:03 prawnsalad

Well, you have all the API to add, remove cookies on a web page. It's not what you want?

laurentj avatar Mar 11 '15 10:03 laurentj

Not really what I'm trying to do. I'm trying to use separate cookie jars per page, while at the moment it is per-profile. ie:

    var page1 = require('webpage').create();
    var page2 = require('webpage').create();

    page1.open('http://domain.com/');
    page2.open('http://domain.com/');

I need page1 and page2 accessing their own cookies. Cookies set on page1 should not be accessible via page2 and visa-versa.

I have managed to hack a semi-working solution by keeping a .cookiejar property on my created page then using page.onResourceRequested and page.onResourceReceived to manage my own cookies, reading and setting the cookie headers as needed. However this does not work for cookies that are set/read using javascript on the webpage itself.

prawnsalad avatar Mar 11 '15 10:03 prawnsalad

We should see if there is a solution in Gecko. Probably by allowing to load the web site in the "private browsing mode"...

laurentj avatar Mar 11 '15 11:03 laurentj

I've no idea where to look, but opening multiple private windows sounds like it would be perfect.

prawnsalad avatar Mar 11 '15 13:03 prawnsalad

Maybe this will be of some use? An addon that allows switching to private sessions, I see it makes use of some XUL privatesession APIs. https://github.com/Infocatcher/Private_Tab

I'm looking blindly so no idea if it's relevant here

prawnsalad avatar Mar 11 '15 13:03 prawnsalad

For the moment, I don't know how to implement this feature. But PhantomJS 2.0 implements it, so we should do it.

laurentj avatar May 01 '16 14:05 laurentj

Having a same problem, would be nice to have this feature. Currently solved by running separate Firefox processes

Paxa avatar Jun 30 '17 08:06 Paxa

Firefox 56 has tab containers. We should see if we can use this feature in SlimerJS.

laurentj avatar Oct 04 '17 09:10 laurentj