Set-Cookie in HTTP header is ignored with AngularJS

后端 未结 6 1512
旧时难觅i
旧时难觅i 2020-12-02 11:50

I\'m working on an application based on AngularJS on client side and Java for my API (Tomcat + Jersey for WS) on server side.

Some path of my API are restricted, if

6条回答
  •  独厮守ぢ
    2020-12-02 12:42

    Just solved a problem like this.

    I was doing this and not working...:

      $cookies.put('JSESSIONID', response.data);
    

    Cookies are saved in the browser, but when I sent a new request, all the cookies were sent exept mine. (my cookie is JSESSIONID)

    then i look in the chrome inspector and i found this:

    THE PROBLEM IS THAT WAS NOT THE CORRECT PATH!!!

    then I tried this and my cookies were sent. yay! :

    $cookies.put('JSESSIONID', response.data, {'path':'/'});
    

    I do not know if this is your case, but this worked for me.

    regards!

提交回复
热议问题