mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Added 'samesite' option for setcookie() (#720)
This commit is contained in:
parent
47c3a1dd20
commit
5ae2d9ee89
2 changed files with 5 additions and 0 deletions
|
@ -355,6 +355,7 @@ $bb_cfg['show_sidebar2_on_every_page'] = false;
|
|||
$bb_cfg['cookie_domain'] = in_array($domain_name, [getenv('SERVER_ADDR'), 'localhost'], true) ? '' : ".$domain_name";
|
||||
$bb_cfg['cookie_secure'] = $domain_ssl ? true : \TorrentPier\Helpers\IsHelper::isHTTPS();
|
||||
$bb_cfg['cookie_prefix'] = 'bb_'; // 'bb_'
|
||||
$bb_cfg['cookie_same_site'] = 'Lax'; // Lax, None, Strict | https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
|
||||
|
||||
// Sessions
|
||||
$bb_cfg['session_update_intrv'] = 180; // sec
|
||||
|
|
|
@ -74,6 +74,8 @@ define('COOKIE_PERSIST', TIMENOW + 31536000);
|
|||
define('COOKIE_MAX_TRACKS', 90);
|
||||
|
||||
/**
|
||||
* Set cookie
|
||||
*
|
||||
* @param $name
|
||||
* @param $val
|
||||
* @param int $lifetime
|
||||
|
@ -83,12 +85,14 @@ define('COOKIE_MAX_TRACKS', 90);
|
|||
function bb_setcookie($name, $val, int $lifetime = COOKIE_PERSIST, bool $httponly = false)
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
return setcookie($name, $val, [
|
||||
'expires' => $lifetime,
|
||||
'path' => $bb_cfg['script_path'],
|
||||
'domain' => $bb_cfg['cookie_domain'],
|
||||
'secure' => $bb_cfg['cookie_secure'],
|
||||
'httponly' => $httponly,
|
||||
'samesite' => $bb_cfg['cookie_same_site'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue