mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-26 02:08:05 -05:00
36 lines
930 B
PHP
36 lines
930 B
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class MY_Security extends CI_Security
|
|
{
|
|
|
|
/**
|
|
* CSRF Set Cookie with samesite
|
|
*
|
|
* @codeCoverageIgnore
|
|
* @return CI_Security
|
|
*/
|
|
public function csrf_set_cookie()
|
|
{
|
|
$expire = time() + $this->_csrf_expire;
|
|
$secure_cookie = (bool)config_item('cookie_secure');
|
|
|
|
if ($secure_cookie && !is_https()) {
|
|
return FALSE;
|
|
}
|
|
|
|
setcookie($this->_csrf_cookie_name,
|
|
$this->_csrf_hash,
|
|
['samesite' => 'Strict',
|
|
'secure' => config_item('cookie_httponly'),
|
|
'expires' => $expire,
|
|
'path' => config_item('cookie_path'),
|
|
'domain' => config_item('cookie_domain'),
|
|
'httponly' => config_item('cookie_httponly')]);
|
|
|
|
log_message('info', 'CSRF cookie sent');
|
|
|
|
return $this;
|
|
}
|
|
}
|