Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set cookie in Chrome Dev tools on localhost

I'm trying to set (change) cookie in Chrome Dev tool, but it only stores the name, not the value.

Steps:

  1. open page at localhost:3000
  2. open dev tools
  3. add new cookie
  4. set name
  5. set value
  6. refresh page

Actual result: the cookie with its name is there, but value is empty.

Funny part - this was working a couple of days ago, can't think of what has changed since then.

OS - MacOS v. 10.14.3 Chrome - v. 73.0.3683.86 (Official Build) (64-bit)

Also I noticed the cookie is highlighted in red color (see MyCookie on the screenshot).

not being able to set cookie in dev tools

Setting cookie for this page works just fine in Firefox.

Already tried:

  1. open page from 127.0.0.1:3000 instead of localhost
  2. restart chrome
  3. restart OS
like image 271
Aleksandr Avatar asked Mar 29 '19 05:03

Aleksandr


People also ask

Can we set cookie in localhost?

You need to set a cookie locally that is Secure , or SameSite:none , or has the __Host prefix. Secure cookies are set only on HTTPS, but not on http://localhost for all browsers.

Why is cookie not being set?

Check out the OPTIONS response header ACCESS-CONTROL-ALLOW-CREDENTIAL whether it is set to true . If the server doesn't allow credentials being sent along, the browser will just not attach cookies and authorization headers. So this could be another reason why the cookies are missing in the POST cross-site request.

How do I add cookies to Chrome dev tools?

Open Chrome DevTools. Click the Application tab to open the Application panel. Under Storage expand Cookies, then select an origin.

How do I get cookies in dev tools?

Right-click and click on Inspect Element to open the developer console. Go to the Storage tab. Expand the Cookies menu and select the website to check cookies. On the right side of the console, you will see the cookies that have been set on the website.


1 Answers

With the new versin of chrome Max-age of cooke can set in following way using
dev tools -> console set document.cookie manually.
document.cookie='token=1234'.
We will get following things Cookie Name: token
Cookie Value: 1234
Expires / Max-Age: 2019-12-26T15:22:22.000Z

like image 195
ayyappa maddi Avatar answered Oct 05 '22 23:10

ayyappa maddi