October 21, 2024
Chicago 12, Melborne City, USA
PHP

Override Cookie constructor in laravel 5.5 to allow rendering site inside an iFrame


Laravel 5.5 will only accept lax, strict or null as sameSite options when setting a cookie and will throw and exception if it is not one of these – before you ask I am stuck with laravel 5.5 for now.

To allow the site to render in an iFrame the cookie needs to be set to SameSite: none

Changing the code in vendor does work, but is not a solution, so I looked at extending the Cookie code and using my own constructor.

I found this ticket:

Laravel 5.5 Override vendor class

but the code I would like to change is in Symfony: vendor/symfony/http-foundation/Cookie.php and there is a CookieServiceProvider in Illuminate with is returning an instance of CookieJar which I can see creates a new instance of the symfony cookie in its make() method

Is there a way to extend the symfony code so that laravel uses my version of the constructor?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video