diff options
author | Andrey Andreev <narf@devilix.net> | 2022-01-05 16:32:10 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2022-01-05 16:32:10 +0100 |
commit | 2fa66ba7c6840ac851ae7da2889e7fb654dcda07 (patch) | |
tree | 70573048d629ecc51804507c7868356fad323860 /system/core/Security.php | |
parent | efc96b71e4b1d13d713d8b2be01796b7d30e6f9b (diff) | |
parent | 1d0315b6b3d7003bfb348ccaf7ee30d2533635de (diff) |
Merge branch '3.1-stable' into develop
Diffstat (limited to 'system/core/Security.php')
-rw-r--r-- | system/core/Security.php | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/system/core/Security.php b/system/core/Security.php index 818b09338..aac308194 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -273,15 +273,35 @@ class CI_Security { return FALSE; } - setcookie( - $this->_csrf_cookie_name, - $this->_csrf_hash, - $expire, - config_item('cookie_path'), - config_item('cookie_domain'), - $secure_cookie, - config_item('cookie_httponly') - ); + if (is_php('7.3')) + { + setcookie( + $this->_csrf_cookie_name, + $this->_csrf_hash, + array( + 'expires' => $expire, + 'path' => config_item('cookie_path'), + 'domain' => config_item('cookie_domain'), + 'secure' => $secure_cookie, + 'httponly' => config_item('cookie_httponly'), + 'samesite' => 'Strict' + ) + ); + } + else + { + $domain = trim(config_item('cookie_domain')); + header('Set-Cookie: '.$this->_csrf_cookie_name.'='.$this->_csrf_hash + .'; Expires='.gmdate('D, d-M-Y H:i:s T', $expire) + .'; Max-Age='.$this->_csrf_expire + .'; Path='.rawurlencode(config_item('cookie_path')) + .($domain === '' ? '' : '; Domain='.$domain) + .($secure_cookie ? '; Secure' : '') + .(config_item('cookie_httponly') ? '; HttpOnly' : '') + .'; SameSite=Strict' + ); + } + log_message('info', 'CSRF cookie sent'); return $this; |