0

We have a Node.js application that invokes a Spring controller. For a PoC purpose, I am creating the cookie in the Spring controller before returning the JSON response to the Node.js application.

Cookie cookie = new Cookie("myCookie", "myCookieValue");
response.addCookie(cookie);

I had my Firebug console open to see if the cookies created in server side are visible but, unfortunately i did not see them.

Also, on the 2nd submit, i tried reading the cookies using request.getCookies() but this is also giving me NULL.

Are the cookies not being received by the browser because it is a Ajax/JSON request-response ?

yathirigan
  • 5,619
  • 22
  • 66
  • 104
  • 1
    There seems to be plenty of material about this question available with a normal web search. If you are having trouble in your particular application, post more complete details and code snippets and folks can help you in your specifics. – Peter Lyons May 08 '15 at 15:35
  • what if you add `cookie.setPath("/")` – ZhongYu May 12 '15 at 13:59
  • i just noticed that, in Chrome --> Developer Tools --> Network , i am able to see my cookie as 'Response Cookie' and in the 'Response Header'. Meanwhile there is another request cookie (created by spring session). It is only this request cookie that is going back in the subsequent requests. The response cookie even though showing up in the browser, it is not going back to the server in subsequent requests. – yathirigan May 12 '15 at 14:01

0 Answers0