Skip to content

Instantly share code, notes, and snippets.

@simonamor
Created August 7, 2020 14:46
Show Gist options
  • Select an option

  • Save simonamor/3949ea3507d357d3a3599305dc3f18bb to your computer and use it in GitHub Desktop.

Select an option

Save simonamor/3949ea3507d357d3a3599305dc3f18bb to your computer and use it in GitHub Desktop.
Patch for Catalyst/Plugin/Session/State/Cookie.pm to add the SameSite header
--- Catalyst/Plugin/Session/State/Cookie.pm.orig 2020-08-07 15:40:56.855643211 +0100
+++ Catalyst/Plugin/Session/State/Cookie.pm 2020-08-07 11:53:35.131890154 +0100
@@ -81,6 +81,10 @@
$cookie->{httponly} = 1
unless defined $cookie->{httponly}; # default = 1 (set httponly)
+ $cookie->{samesite} = $cfg->{cookie_samesite};
+ $cookie->{samesite} = "Lax"
+ unless defined $cookie->{ samesite}; # default = Lax
+
return $cookie;
}
@simonamor
Copy link
Author

simonamor commented Aug 7, 2020

Requires CGI::Simple::Cookie 1.18 or higher to support samesite

__PACKAGE__->config('Plugin::Session' => {
   cookie_samesite  => "Strict",  # or Lax or None
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment