brillout
brillout

Reputation: 7444

Secure Cookie on `http://localhost`

I'm trying to set a secure cookie on http://localhost:3000:

Set-Cookie: loggedUser=brillout; Max-Age=315360000; Path=/; HttpOnly; Secure

But Chrome complains:

This Set-Cookie was blocked because it had the "Secure" attribute but was not received over a secure connection.

Yet, according to MDN, it should work:

A cookie with the Secure attribute is sent to the server only with an encrypted request over the HTTPS protocol, never with unsecured HTTP (except on localhost)

Is it possible to set Secure while being http://localhost? Developing on https://localhost instead of http://localhost is not an option.

Upvotes: 10

Views: 14233

Answers (1)

Prabhsharan Sandhu
Prabhsharan Sandhu

Reputation: 56

At the time of writing, the Chrome browser stands at Version 100.0.4896.75, the browser is not giving an error or warning. I can easily set cookie from my localhost with attributes given by you. But If you are still getting errors, you could easily install the SSL certificate on your localhost (read this blog) and it will resolve your problem.

Hope this helped you!

Upvotes: 3

Related Questions