Skip to content

Commit

Permalink
fixed bugs in set_cookie functions inside IO Class
Browse files Browse the repository at this point in the history
  • Loading branch information
ronmarasigan committed Nov 2, 2022
1 parent b0c3ccb commit a96616a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
6 changes: 3 additions & 3 deletions app/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
| LavaLust Version
| -------------------------------------------------------------------
*/
$config['VERSION'] = '3.1.0';
$config['VERSION'] = '3.1.1';

/*
| -------------------------------------------------------------------
Expand Down Expand Up @@ -213,10 +213,10 @@
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = TRUE;
$config['cookie_secure'] = FALSE;
$config['cookie_expiration'] = 86400;
$config['cookie_httponly'] = FALSE;
$config['cookie_samesite'] = 'None';
$config['cookie_samesite'] = 'Lax';

/*
|--------------------------------------------------------------------------
Expand Down
30 changes: 12 additions & 18 deletions scheme/kernel/Io.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ public function set_cookie($name, $value = '', $expiration = 0, $options = array
{
if(count($options) > 0)
{
foreach($options as $key => $value)
foreach($options as $key => $val)
{
if(isset($options[$key]) && $options[$key] != 'expiration')
{
$arr[$key] = $value;
$arr[$key] = $val;
} else {
$arr[$key] = config_item('cookie_' . $key);
}
Expand All @@ -180,27 +180,21 @@ public function set_cookie($name, $value = '', $expiration = 0, $options = array
} else {
$arr['expiration'] = ($expiration > 0) ? time() + $expiration : 0;
}

foreach($lists as $key)
{
$arr[$key] = config_item('cookie_' . $key);
}

//check for PHP Version later than 7.3.0
if (PHP_VERSION_ID < 70300)
{
setcookie($arr['prefix'].$name, $value, $arr['expiration'], $arr['path'].'; samesite='.$arr['samesite'], $arr['domain'], $arr['secure'], $arr['httponly']);
} else {
setcookie($arr['prefix'].$name, $value,
array(
'expires' => $arr['expiration'],
'path' => $arr['path'],
'domain' => $arr['domain'],
'secure' => (bool) $arr['secure'],
'httponly' => (bool) $arr['httponly'],
'samesite' => $arr['samesite']
));
}
setcookie($arr['prefix'].$name, $value,
array(
'expires' => $arr['expiration'],
'path' => $arr['path'],
'domain' => $arr['domain'],
'secure' => (bool) $arr['secure'],
'httponly' => (bool) $arr['httponly'],
'samesite' => $arr['samesite']
));
}

/**
Expand Down

0 comments on commit a96616a

Please sign in to comment.