summaryrefslogtreecommitdiffstats
path: root/system/core/Input.php
diff options
context:
space:
mode:
authorGeorge Petculescu <gxgpet@gmail.com>2021-04-02 01:41:29 +0200
committerGeorge Petculescu <gxgpet@gmail.com>2021-04-02 01:41:29 +0200
commit0cf5aa1a17bf0fd91797a943b8e696a454f5d326 (patch)
treef06da461f3a771988915cc0ec7422c1f7039f22d /system/core/Input.php
parent4f6d9ba5b6b690f3b7b30c20926463d41117017a (diff)
Switching to setcookie for PHP >= 7.3
Diffstat (limited to 'system/core/Input.php')
-rw-r--r--system/core/Input.php25
1 files changed, 20 insertions, 5 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index fbe9c59b0..451737167 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -365,11 +365,26 @@ class CI_Input {
log_message('error', $name.' cookie sent with SameSite=None, but without Secure attribute.');
}
- $cookie_header = 'Set-Cookie: '.$prefix.$name.'='.rawurlencode($value);
- $cookie_header .= ($expire === 0 ? '' : '; expires='.gmdate('D, d-M-Y H:i:s T', $expire));
- $cookie_header .= '; path='.$path.($domain !== '' ? '; domain='.$domain : '');
- $cookie_header .= ($secure ? '; secure' : '').($httponly ? '; HttpOnly' : '').'; SameSite='.$samesite;
- header($cookie_header);
+ if (is_php('7.3'))
+ {
+ $setcookie_options = array(
+ 'expires' => $expire,
+ 'path' => $path,
+ 'domain' => $domain,
+ 'secure' => $secure,
+ 'httponly' => $httponly,
+ 'samesite' => $samesite,
+ );
+ setcookie($prefix.$name, $value, $setcookie_options);
+ }
+ else
+ {
+ $cookie_header = 'Set-Cookie: '.$prefix.$name.'='.rawurlencode($value);
+ $cookie_header .= ($expire === 0 ? '' : '; expires='.gmdate('D, d-M-Y H:i:s T', $expire));
+ $cookie_header .= '; path='.$path.($domain !== '' ? '; domain='.$domain : '');
+ $cookie_header .= ($secure ? '; secure' : '').($httponly ? '; HttpOnly' : '').'; SameSite='.$samesite;
+ header($cookie_header);
+ }
}
// --------------------------------------------------------------------