Conditions | 1 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function setCookie($name, $value, $exp = 3600, $options = []): self |
||
22 | { |
||
23 | $cookieOptions = [ |
||
24 | 'expires' => time() + $exp, |
||
25 | ]; |
||
26 | |||
27 | // SameSite none and secure will be required for tools to work inside iframes |
||
28 | $sameSiteOptions = [ |
||
29 | 'samesite' => 'None', |
||
30 | 'secure' => false, |
||
31 | 'httponly' => true, |
||
32 | ]; |
||
33 | |||
34 | setcookie($name, $value, array_merge($cookieOptions, $sameSiteOptions, $options)); |
||
35 | |||
36 | // Set a second fallback cookie in the event that "SameSite" is not supported |
||
37 | setcookie("LEGACY_".$name, $value, array_merge($cookieOptions, $options)); |
||
38 | |||
39 | return $this; |
||
40 | } |
||
42 |