Search code examples
angularjscookiessamesite

samesite is not working for ngcookies in Angular JS


I am using ngCookies for my Angular JS project. I am trying to set samesite option as strict(as mentioned below), but it's not working. Could anyone please help me how can I set samesite for Angular JS cookies?

I tried as per this Angular JS documentation, I see all other options are getting set but the samesite is not getting set as 'strict' in chrome. Reference

MyCookiesService.put('user-details', JSON.stringify(session), {
                        expires: expire.toUTCString(),
                        path: '/',
                        secure: true,
                        samesite: 'strict'
                    });

Solution

  • Solved via comment from Nirmala.

    My issue required samesite: 'none'. Confirmed code works correctly when upgraded to Angular 1.7.1+

    MyCookiesService.put('user-details', JSON.stringify(session), {
                            expires: expire.toUTCString(),
                            path: '/',
                            secure: true,
                            samesite: 'strict'
                        });