Domain and cookie path with jax-rs

I am using jax-rs and trying to add a cookie to my answer. The problem is that when adding a cookie, the following path:

new NewCookie("cookie-name", "cookie-value");

A cookie is attached only to requests of the same path. For example, if I add a cookie to the request "/ myapp / users / login", I do not see this cookie when other requests are called. I think the explanation for this is that for some reason, the path to the cookie is "/ myapp / users", so when calling "myapp / someotherpath" the cookie is not attached.

I tried using a different NewCookie constructor where I can set the domain and path, but could not get it working, can someone give me an example of setting the domain and the paths that will attach the cookie to all requests? Shouldn't it be the default?

+4
source share
1 answer

To attach a cookie to all requests, the domain and path must be: domain = ""; path = "/"

Thus, creating a cookie will look like this:

NewCookie("cookie-name", "cookie-value", "/", "", "comment", 100, false);
+5
source

All Articles