0

I am using a CookieSerializer and I am trying to set HostOnly to this cookie but I can't find anything related to this.

The column HostOnly I can see just in Firefox inspect. Not available in Safari or in Google Chrome.

This is how my cookie is defined:

 DefaultCookieSerializer serializer = new DefaultCookieSerializer();
    serializer.setCookieName("M_SESSION");
    serializer.setCookiePath("/");
    serializer.setDomainNamePattern("^((\\w+\\.)+\\w+\\.[a-z]+)$");
    serializer.setUseHttpOnlyCookie(true);
    return serializer;

Any advice how to do this?

Falvius
  • 47
  • 1
  • 1
  • 6
  • *The above can be summed up by "Host-only is the default". That is, if Domain is not specified, the cookie can only be read by the exact domain that has set the cookie. This can be loosened by setting the Domain attribute when setting a cookie.* From [this answer](https://stackoverflow.com/a/28320172/2970947). – Elliott Frisch Nov 08 '22 at 17:45
  • @ElliottFrisch so if i remove the " setDomainNamePattern("^((\\w+\\.)+\\w+\\.[a-z]+)$");" it should work ? – Falvius Nov 08 '22 at 17:58
  • It should be host-only. Good luck! – Elliott Frisch Nov 08 '22 at 18:00

1 Answers1

1

In your case removing "serializer.setDomainNamePattern("^((\w+\.)+\w+\.[a-z]+)$");" should solve your issue.

Buda Sergiu Flavius
  • 210
  • 1
  • 3
  • 13