Cookies sent from browser not found in HttpServletRequest

Viewed 138

Not all the cookies shown by Chrome Dev Tools as part of the Request Header are found in the HttpServletRequest object.

Here is a screenprint from Chrome Dev Tools, showing the request headers for the GET HTTP request. You can see that the "cookie" includes the "_fbp" cookie: cookie request header

From the Chrome Dev Tools application tab, you can see that the "_fbp" cookie is from my same Domain and has not expired and is for Path / so it should be included (which it was): cookie details

We're running a Java Spring MVC backend and when the request comes to the controller endpoint, we have the "HttpServletRequest request" parameter.

Examining that "request" object, I find that it has some of the cookies which were observed as part of the request, but not all of them... and specifically not the "_fbp" cookie I'm looking for.

Tried examining the cookies in all the following manners:

  1. Object rhc = request.getHeader("Cookie");

  2. Cookie wuc = org.springframework.web.util.WebUtils.getCookie(request, "_fbp");

  3. parameter @CookieValue(name="_fbp", required=false) String fbpCookie

but no matter how I inspect that request, the "_fbp" cookie is not there. I noticed that most of the other cookies that are not found all have names beginning with underscores so I suspected maybe that is a naming convention that is ignored by Spring MVC but couldn't find any such rule.

Can anyone help explain the missing cookies? How can I get that "_fbp" cookie value for server-side processing? Appreciate any help.

0 Answers
Related