You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
940 B

  1. <?php
  2. /**
  3. * Support samesite cookie flag in both php 7.2 (current production) and php >= 7.3 (when we get there)
  4. * From: https://github.com/GoogleChromeLabs/samesite-examples/blob/master/php.md and https://stackoverflow.com/a/46971326/2308553
  5. */
  6. function setcookieSameSite($name, $value, $expire=0, $path ='/', $domain="", $httponly="HttpOnly", $secure=false, $samesite="Lax")
  7. {
  8. if (PHP_VERSION_ID < 70300) {
  9. setcookie($name, $value, $expire, "$path; samesite=$samesite", $domain, $secure, $httponly);
  10. }
  11. else {
  12. setcookie($name, $value, [
  13. 'expires' => $expire,
  14. 'path' => $path,
  15. 'domain' => $domain,
  16. 'samesite' => $samesite,
  17. 'secure' => $secure,
  18. 'httponly' => $httponly,
  19. ]);
  20. }
  21. }
  22. ?>