1

Looking at the solutions given in $http doesn't send cookie in Requests

I've added below line inside my App.Config,

    $httpProvider.defaults.withCredentials = true;

Also updated updated $http call with {withCredentials: true} as:

    return $http.get(url, {withCredentials: true});

Additionally, tried setting below header in my server side code (servlet):

    response.setHeader("Access-Control-Allow-Credentials", "true");

However, still not able to read cookie from request object in my Filter Class. Can someone please help me and tell, what am I missing?

Community
  • 1
  • 1
  • Are you trying to read cookies set from the same domain or higher? If the cookie was set in a subdomain it will probably not work. Also, try to check the browser console to see if the cookie is set. – brainwash Jan 08 '15 at 09:32
  • 1
    I found a solution for my case. Might be helpful to others: While setting cookie in my servlet I set the `code`accessCookie.setPath("/MyApp");`code` Problem was: Cookie was by default created for Path "/MyApp/app" which is URI for Login Servlet where I was setting cookie and I was trying to access it for REST URLs "/MyApp/rest". I referred [RFC2109](https://www.ietf.org/rfc/rfc2109.txt) and found that Path set for cookie decides what set of requests will have access to the cookie so I explicitly changed it to `code`accessCookie.setPath("/MyApp");`code` and problem got resolved. – Saurabh Agrawal Jan 08 '15 at 12:28
  • Possible duplicate of [$http doesn't send cookie in Requests](http://stackoverflow.com/questions/17064791/http-doesnt-send-cookie-in-requests) – Dave Aug 08 '16 at 15:17

0 Answers0