About SameSite cookie attribute and dealing with it in PHP/Laravel Shopify Apps

Highlighted
Shopify Partner
49 1 10

Hello community,

 

I just wrote an article about SameSite=None cookie attribute and how to implement its solution in PHP/Laravel apps.

Give it a read and let me know your thoughts or if I missed something. Also if it can be improved in any way.

 

Dealing with Chrome SameSite cookie attribute in Shopify Apps made with PHP/Laravel 

 

Thanks :)

2 Likes
Highlighted
Shopify Partner
192 11 20

Hi @zubairmohsin ,
That's great! May I know how to implement same in Codeigniter?
Thank you

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
Give a try to Shopify APP: https://apps.shopify.com/short-track
0 Likes
Highlighted
Shopify Partner
49 1 10

Hi Jivan, can you please share more information about your current setup?

What CodeIgniter version you are using?
What PHP version you are using? ( Because SameSite attribute is supported as of PHP 7.3, not earlier versions )
Can you use "composer" in you CI project?

Let me know. Thanks :)

0 Likes
Highlighted
Shopify Partner
192 11 20

Thank you for your quick reply!
I'm using CI 3.0.1 and PHP Version 7.2.24. If its not not supported in earlier version, how to deal with that? 

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
Give a try to Shopify APP: https://apps.shopify.com/short-track
0 Likes
Highlighted
Shopify Partner
49 1 10

You can try and upgrade it to 7.3.0. I recommend doing it on a "dev/staging" server first.

 

As per documentation, CodeIgniter 3 cookie helper `set_cookie` does not see to support SameSite cookie attribute.

 

So, after upgrading PHP version, use native PHP method `setcookie` to set your cookies and provide `samesite` attribute value.

0 Likes
Highlighted
Shopify Partner
192 11 20

Thanks, but what about browsers that are not supported? APP will crash in those browsers. As this will be applicable to only Chrome 80+ and some other

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
Give a try to Shopify APP: https://apps.shopify.com/short-track
0 Likes
Shopify Partner
49 1 10

You are right. I am assuming you cannot use "Composer" in your project. If you could use composer, it was simply pulling this https://github.com/jenssegers/agent  package and use the code I shared in article.

 

What you can do now is look at this package's code, or,  look at https://www.php.net/manual/en/function.get-browser.php  function in core PHP, and come up with a solution for yourself. 

 

If you do come up with a solution, please share it here for others. Best of luck.

0 Likes