I want to delete cookie on server (by means of setting Expires
to the past). How can I do this with javax.ws.rs.core.NewCookie
? I'm trying this, but it doesn't work:
return Response.ok()
.entity("hello world!")
.cookie(
new NewCookie(
"foo",
"",
"/",
".example.com",
1,
"no comment",
0, // maxAge
false
)
)
.build();
This snippet produces this HTTP header:
Set-Cookie:foo=;Version=1;Comment="no comment";Domain=.example.com;Path=/
This header doesn't delete the cookie from the server. What is a possible workaround?