In my web app i am setting response cookies this way:
Cookie testCookie = new Cookie("test", "mycookie");
testCookie.setHttpOnly(true);
testCookie.setPath("/");
testCookie.setMaxAge(3600);
testCookie.setSecure(true);
response.addCookie(testCookie); // Response is of type HttpServletResponse
The client that is performing the requests is running in localhost.
When i look at the request in chrome, i see that cookie tab and see that the cookie was received but I cannot find this cookie in chrome when i look in the Application->Cookies tab and the other requests i do after this was done, do not send cookies.
Also, in jetty 11 i cannot seem to be able to set the SameSite attribute of the cookie.
How can i set this cookie and is it normal that an httpOnly cookie is not visible in the Application tab in chrome? How can i verify if it was set or not?
EDIT: Additional details I am running the client in https://localhost and the server is using https with a self signed certificate. The cookie i am receiving seems corect from the response but then chrome does not seem to save it.
Our experience is that Chrome will reject/drop any
Set-Cookiewithout aSameSitevalue set.The behavior in Jetty 11 ...
jakarta.servlet.http.Cookiehas no setters/getters for "SameSite" (that's a feature of the next Servlet API release).ServletContextattributeorg.eclipse.jetty.cookie.sameSiteDefaultcontains the default value for theSameSitecookie attribute. (use one of valueNone,Strict, orLax). If this attribute is unset there is noSameSitevalue provided with your cookies.SameSite, andHttpOnlywith cookie comments in Jetty to control specific CookieSameSitebehavior.Example:
When evaluating these changes in your browser, confirm that the
Set-Cookieresponse header is what you want first, then look at the application tab.Note that Chrome has tons of special rules for domain names that are IP addresses, single label domains, and reserved hostnames such as "test" or "localhost", etc. These do not work normally for TLS/SSL, SameSite, CORs, Preflight requests, etc. Avoid using any of these while you are testing, use a fully qualified hostname when you can, otherwise you'll be surprised by these rules.