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

Can only set Cookies for the current domain #14179

Closed
maxgu opened this issue Apr 6, 2016 · 6 comments
Closed

Can only set Cookies for the current domain #14179

maxgu opened this issue Apr 6, 2016 · 6 comments
Labels

Comments

@maxgu
Copy link

maxgu commented Apr 6, 2016

my request

{
  'url' => string(80) "http://127.0.0.1:4444/wd/hub/session/22efd150-fc0b-11e5-bd8f-235d4dbe7530/cookie"
  'content_type' =>string(30) "application/json;charset=UTF-8"
  'http_code' => int(500)
  'header_size' => int(123)
  'request_size' =>  int(272)
  'filetime' =>  int(-1)
  'ssl_verify_result' =>  int(0)
  'redirect_count' =>  int(0)
  'total_time' =>  double(0.116094)
  'namelookup_time' =>  double(2.3E-5)
  'connect_time' =>  double(2.3E-5)
  'pretransfer_time' =>  double(2.4E-5)
  'size_upload' =>  double(81)
  'size_download' =>  double(6531)
  'speed_download' =>  double(56256)
  'speed_upload' =>  double(697)
  'download_content_length' =>  double(6531)
  'upload_content_length' =>  double(81)
  'starttransfer_time' =>  double(0.116078)
  'redirect_time' =>  double(0)
  'redirect_url' =>  string(0) ""
  'primary_ip' =>  string(9) "127.0.0.1"
  'certinfo' =>  array(0) {
  }
  'primary_port' =>  int(4444)
  'local_ip' =>  string(9) "127.0.0.1"
  'local_port' =>  int(35511)
}

response

{
  "sessionId": "22efd150-fc0b-11e5-bd8f-235d4dbe7530",
  "status": 24,
  "value": {
    "message": "{\"errorMessage\":\"Can only set Cookies for the current domain\",\"request\":{\"headers\":{\"Accept\":\"application/json\",\"Content-Length\":\"81\",\"Content-Type\":\"application/json;charset=UTF-8\",\"Host\":\"127.0.0.1:4444\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"post\":\"{\\\"cookie\\\":{\\\"name\\\":\\\"X_REQUESTED_WITH\\\",\\\"value\\\":\\\"Codeception\\\",\\\"domain\\\":\\\"localhost\\\"}}\",\"url\":\"/cookie\",\"urlParsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"cookie\",\"directory\":\"/\",\"path\":\"/cookie\",\"relative\":\"/cookie\",\"port\":\"\",\"host\":\"\",\"password\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"source\":\"/cookie\",\"queryKey\":{},\"chunks\":[\"cookie\"]},\"urlOriginal\":\"/session/22efd150-fc0b-11e5-bd8f-235d4dbe7530/cookie\"}}",
    "screen": "iVBORw0K..."
  }
}

what i do wrong?

@gouchaoer
Copy link

have you solved your problem?p

@maxgu
Copy link
Author

maxgu commented Apr 27, 2016

no,
i set cookie on server side

@gouchaoer
Copy link

gouchaoer commented May 6, 2016

After many trial and error, I finally know how to reproduce this.
if your phantomjs get a.domain.com/path and immidiately set a cookie like .domain.com, everything is ok.
but if you set a cookie with domain like a.domain.com or NULL, phantomjs throw this exception

@mudkippzs
Copy link

@gouchaoer Sorry but that explanation is illegible.

It seems to answer the question but I can't understand what you're saying

@Izkata
Copy link

Izkata commented Sep 27, 2017

@mudkippzs For the URL "a.domain.com/path":

  • Setting a cookie without specifying the domain fails
  • Setting a cookie using this domain fails: "a.domain.com"
  • But setting a cookie using this domain succeeds: ".domain.com"

I get "Can only set Cookies for the current domain" on only some hosts when the domain is not specified in the cookie (others succeed; no idea of the pattern), and "Unable to set Cookie" in the second case on those same ones. Only the third way of specifying the cookie's domain seems to work consistently.

In my case, I was also able to successfully set it using ".a.domain.com".

@stale stale bot added the stale label Dec 26, 2019
@stale
Copy link

stale bot commented Dec 29, 2019

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

@stale stale bot closed this as completed Dec 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants