BCJTI / ng2-cookies

Simple library to deal with cookies in Angular2
64 stars 31 forks source link

It seems that it doesn't save all cookies #35

Closed matthiaslexer closed 7 years ago

matthiaslexer commented 7 years ago

Hey Guys,

Could it be that your library only takes the last 'set-cookie' object from the header? I've discovered the following problem: The response header from the login function of the site I'm calling has two set-cookie objects:

set-cookie:id=c90ee0f20c1ef9c5995894321a6dc518
set-cookie:ict-lb-oracle=orab1

But If i'm calling Cookie.getAll(), i only get the second cookie. Can i do anything to fix it?

Kind Regards, Matthias

Bigous commented 7 years ago

Hi Matthias, The browser has only one cookie object containing all the cookie values... document.cookie. See it here. Cookie.getAll() iterates over the values and parses it to an array. Could you look at it at the console of your application to see if all the cookies are available? If the values are at document.cookie and are not in the return of Cookie.getAll() you found a bug (and I'll ask you to post the content of document.cookie here so we can debug and see what's happening). If the value is not on document.cookie your browser (or a security software like McAffee) is choosing not to save it for some reason (unsafe content for example) and we will not be able to get the content.

matthiaslexer commented 7 years ago

Hi Bigous, you're right the cookie isn't there if i execute document.cookie. Does your library support to get a cookie from another site?

Thanks in advance, Matthias