GoogleChromeLabs / samesite-examples

Examples of using the SameSite cookie attribute in a variety of language, libraries, and frameworks.
https://web.dev/samesite-cookies-explained
Apache License 2.0
366 stars 62 forks source link

Set cookie in shopify extension #20

Open Sarimkhan-stack opened 4 years ago

Sarimkhan-stack commented 4 years ago

I'm working on shopify extension on php codeigniter. 7.1 php version. I'm receiving this error while i'm installing extension on shopify. The app couldn’t be loaded Then i add this code in the default controller:

header('Set-Cookie: same-site-cookie=foo; SameSite=Lax');
header('Set-Cookie: cross-site-cookie=bar; SameSite=None; Secure');

But still i'm receiving above error. Even the cookie was created as i check it on Application > Storage > Cookies. Can anyone guide me that what is missing or why i'm still getting this error on chrome 80. Thanks!

rowan-m commented 4 years ago

Those header() calls are examples of how to set a cookie with those attributes. You cannot drop them in directly, you need to replace the places where you are setting a cookie with these.

If you look at this guide: https://www.chromium.org/updates/same-site/test-debug you should be able to identify which cookies are required. Then work out where they are set in your code. That is where you will need to adjust the call to ensure the SameSite=None; Secure attributes are set for that specific cookie.