Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

addCookie always returns false in v2.1.1 #14047

Closed
ng-cat opened this issue Feb 26, 2016 · 22 comments
Closed

addCookie always returns false in v2.1.1 #14047

ng-cat opened this issue Feb 26, 2016 · 22 comments

Comments

@ng-cat
Copy link

ng-cat commented Feb 26, 2016

Hi,

I've upgrade PhantomJs from 2.0 to 2.1.1 and now in this simple code:

for (var i = 0; i < options.cookies.length; i++) {
    if (!phantom.addCookie({
            'name': options.cookies[i].name,
            /* required property */
            'value': options.cookies[i].value,
            /* required property */
            'domain': options.cookies[i].domain /* required property */
        })) {
        errMsg = "Error setting. Unable to set cookie value.";
        sendWarningMessage(errMsg);
        if (debugMode) console.log(errMsg);
        //phantom.exit( 104 );  // ERROR -4
    }
}

addCookie always returns false, also if cookies are correctly added.
Infact removing this part of code, the page is redirect to login page cause of missing cookies.
Any ideas?

@vitallium
Copy link
Collaborator

Thanks a lot for filing this issue! We'll triage and take a look at it as soon as possible!

trabulmonkee pushed a commit to trabulmonkee/selenium that referenced this issue Mar 6, 2016
vitallium added a commit to vitallium/phantomjs that referenced this issue Mar 7, 2016
Consider CookierJar return a boolean value on
addCookie or removeCookie methods.

Issue: ariya#14047
vitallium added a commit to vitallium/phantomjs that referenced this issue Mar 16, 2016
Consider CookierJar return a boolean value on
addCookie or removeCookie methods.

Issue: ariya#14047
@ti2m
Copy link

ti2m commented Mar 19, 2016

I compiled and tested #14068 on ubuntu and it fixes my problems of not being able to set session values. Thanks!

vitallium added a commit that referenced this issue Apr 11, 2016
Consider CookierJar return a boolean value on
addCookie or removeCookie methods.

Issue: #14047
@vitallium
Copy link
Collaborator

Landed in d038837

@bgever
Copy link

bgever commented Jul 23, 2016

@vitallium When is this fix landing in a release? I depend on the phantomjs-prebuilt npm package which is not able to get this patch unless it's an official release.

@mschlebusch
Copy link

@vitallium @bgever The same here. We need this fix because we need to set cookies in our cucumber web test cases. Currently I'm setting up an environment to be able to build an own version based on the latest master branch.

@vitallium
Copy link
Collaborator

This fix will be available in the next version.

@mschlebusch
Copy link

@vitallium Thanks for your update. When we can expect the new version?

@IljaN
Copy link

IljaN commented Jul 26, 2016

I built phantomjs from master

git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout master
git submodule init
git submodule update

Still unable to set Cookie via Codeception.
Got a build error when checking out d038837

@lougreenwood
Copy link

@vitallium Same issue here - I see that 2.2.0 milestone is 5 months late and has 10 issues still open, is it fair to say that this fix wont be made available through a point -release release anytime soon?

Thanks :)

@danielmconrad
Copy link

Any update on this? With the update to macOS Sierra, 1.x and 2.0.x don't work due to segfault, and 2.1 has this cookie issue, which means no working version.

@JorisVanEijden
Copy link

How hard is it to create a 2.1.2 release with just this bugfix?

@gimler
Copy link

gimler commented Nov 5, 2016

actually you can't build phantomjs from source ;( #14585

jscn pushed a commit to infoxchange/ixprofile-client that referenced this issue Nov 7, 2016
1) The cookie *must* set the domain, and it must be the same as the
   browser's domain.
2) Setting the cookie always causes an exception with Selenium 2.1.13,
   even when it's successful - see
   ariya/phantomjs#14047
jscn pushed a commit to infoxchange/ixprofile-client that referenced this issue Nov 7, 2016
1) The cookie *must* set the domain, and it must be the same as the
   browser's domain.
2) Setting the cookie always causes an exception with Selenium 2.1.13,
   even when it's successful - see
   ariya/phantomjs#14047
jscn pushed a commit to infoxchange/ixprofile-client that referenced this issue Nov 7, 2016
1) The cookie *must* set the domain, and it must be the same as the
   browser's domain.
2) Setting the cookie always causes an exception with Selenium 2.1.13,
   even when it's successful - see
   ariya/phantomjs#14047
jscn pushed a commit to infoxchange/ixprofile-client that referenced this issue Nov 7, 2016
1) The cookie *must* set the domain, and it must be the same as the
   browser's domain.
2) Setting the cookie always causes an exception with Selenium 2.1.13,
   even when it's successful - see
   ariya/phantomjs#14047
Nek- pushed a commit to Nek-/phantomjs that referenced this issue Dec 19, 2016
Consider CookierJar return a boolean value on
addCookie or removeCookie methods.

Issue: ariya#14047
@rogamoore
Copy link

When will this be released?

nkovacs added a commit to nkovacs/selenium-standalone-phantomjs that referenced this issue Feb 6, 2017
@nkovacs
Copy link

nkovacs commented Feb 7, 2017

This fixed our issue. I've built a 64 bit phantomjs 2.1.1 with d038837 cherry-picked using the instructions in the deploy directory, if someone needs it, the binary is here: https://github.com/nkovacs/selenium-standalone-phantomjs/tree/62f2a2a56ddbce1c13218aabe60f516afdeffdd8

@clutch2sft
Copy link

I applaud the work - thank you. Running with your binary it seems that my cookies aren't actually applied to the browser session. In working with a logged in session where state is maintained by the cookies; the website will not recognize the cookies applied to a new browser session - IE: requires loggin even though my session cookies are valid. Haven't looked at your code to see what is going on there but it seems that not all my cookies are getting attached back with add_cookie. I can however, take the same cookies and slam them into chrome with add_cookie and the website doesn't request a new login.

@NavyCoat
Copy link

Can you make 2.1.2 with this fix?
@ariya @vitallium

@jackric
Copy link

jackric commented Jun 22, 2017

Please make a release with this fix
@ariya @vitallium

@jtemplet
Copy link

jtemplet commented Jul 6, 2017

Just wanted to follow up to see if there was a plan to make a release soon. Thank you for all your effort!

@BruceKinchin
Copy link

Hey there, is there likely to be a 2.1.2 with this fix? Many thanks!

@Ryllari
Copy link

Ryllari commented Aug 21, 2017

I have this fork with d038837 cherry-picked on 2.1.1: https://github.com/ryllari/phantomjs
The fix is in tag 2.1.2. (https://github.com/Ryllari/phantomjs/tree/2.1.2)

@jackric
Copy link

jackric commented Aug 21, 2017

If you get impatient waiting for a release, try using Chrome headless instead, with chromedriver

@insightfuls
Copy link

I am still running version 2.0.0, because it works well for me.

I did have a problem on Sierra (funnily enough, only on a new Macbook Pro; my 2011 Macbook Pro, although upgraded to Sierra, was fine). I got the message Killed: 9. I read on Stack Overflow that this can be caused by an improper Mach-O header or some such thing in upx-compressed executables. So I installed upx (I use MacPorts, so I did sudo port install upx and I got version 3.94). I then ran upx -d phantomjs and then upx phantomjs and lo and behold, it worked! So I am still happily running phantomjs 2.0.0.

Thought this might help someone.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests