Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome doesn't create cookie for domain=localhost in broken https

I have application on my localhost in https. But the certification on localhost is broken.

Below, response header. Problem: MyCookie is not created:

MyCookie=MyValue;Path=/;Domain=localhost;Secure; HttpOnly

But for this header. The cookie is created:

MyCookie=MyValue;Path=/;Secure; HttpOnly

Is there any Chrome politics which disallow create cookie for broken https page which set domain in the header?

like image 677
lukastymo Avatar asked Nov 15 '11 09:11

lukastymo


People also ask

Can you set a cookie on localhost?

Secure cookies are set only on HTTPS, but not on http://localhost for all browsers. And because SameSite:none and __Host also require the cookie to be Secure , setting such cookies on your local development site requires HTTPS as well.

What is set with SameSite none without secure?

SameSite=None requires Secure The warning appears because any cookie that requests SameSite=None but is not marked Secure will be rejected. To fix this, you will have to add the Secure attribute to your SameSite=None cookies. A Secure cookie is only sent to the server with an encrypted request over the HTTPS protocol.


2 Answers

Explicit setting domain cookie on localhost doesn't work for chrome.

From this:

You can only set domain cookies for registry controlled domains, i.e. something ending in .com or so, but not IPs or intranet hostnames like localhost

like image 64
lukastymo Avatar answered Oct 05 '22 02:10

lukastymo


Try to set

cookie_domain = ""

By this the cookie can be created and will work.

I've tried it and it was working fine.

like image 26
Richa Avatar answered Oct 05 '22 00:10

Richa