document.cookies is empty string

See original GitHub issue

I am expecting cookie.save to save a cookie. The following code shows how document.cookies is empty after using the save function.

import cookie from 'react-cookie'

cookie.save('session', 'SESSIONTOKEN')
console.log(document.cookies) // => ""
console.log(cookie.load('session', true)) // => "SESSIONTOKEN"

What am I doing wrong or understanding wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
0xsvencommented, Nov 28, 2016

This line:

https://github.com/thereactivestack/react-cookie/blob/master/src/cookie.js#L4

is what breaks it. It assumes to be in node when it’s really in the browser.

0reactions
0xsvencommented, Nov 30, 2016

this library is pretty neat btw.! Thank’s for developing it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript document.cookie always returns empty string
Answer: Can happen when there are only cookies with the HttpOnly flag set. No you can't write these cookies from JS, but you...
Read more >
Document.cookie returns empty string if any ... - Google Groups
Document.cookie returns empty string if any cookie in the domain has non-ASCII characters. 2214 views.
Read more >
Javascript document.cookie always returns empty string
JavaScript : Javascript document. cookie always returns empty string [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] JavaScript ...
Read more >
document.cookie return empty string for the csrf token with ...
Here csrf_token is set using document.cookie. Since that is empty, false value is set. If need more info, let me know. Flags: needinfo?(coderrajput) ......
Read more >
Web - Client | XSS Stored 1, I have no cookie WTF ... - Root Me
console.log(document.cookie) on the dev console prints an empty string, and in the cookies section in the browser I don't see any cookies.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found