Skip to content

Commit e056097

Browse files
authored
Merge pull request #1585 from mambax7/feature/fix_xoops_setcookie()
fix for xoops_setcookie()
2 parents 8ea667e + ae00971 commit e056097

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

htdocs/include/xoopssetcookie.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* @param string $name The name of the cookie.
2323
* @param string|null $value The value of the cookie.
2424
* @param int $expire The time the cookie expires. This is a Unix timestamp.
25-
* @param string $path The path on the server in which the cookie will be available on.
26-
* @param string $domain The (sub)domain that the cookie is available to.
25+
* @param string|null $path The path on the server in which the cookie will be available on.
26+
* @param string|null $domain The (sub)domain that the cookie is available to.
2727
* @param bool|null $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection.
2828
* If null, it will be auto-detected.
2929
* @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol.
@@ -34,8 +34,8 @@ function xoops_setcookie(
3434
string $name,
3535
?string $value = '',
3636
int $expire = 0,
37-
string $path = '/',
38-
string $domain = '',
37+
?string $path = '/',
38+
?string $domain = '',
3939
?bool $secure = null,
4040
bool $httponly = true,
4141
string $samesite = 'Lax'
@@ -50,6 +50,9 @@ function xoops_setcookie(
5050
if (!is_string($host)) {
5151
$host = ''; // Fallback for invalid XOOPS_URL
5252
}
53+
if (!is_string($domain)) {
54+
$domain = ''; // Fallback for invalid domain
55+
}
5356

5457
// Validate the domain BEFORE using it.
5558
if (class_exists('\Xoops\RegDom\RegisteredDomain')) {

htdocs/install/page_end.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
include_once __DIR__ . '/../class/logger/xoopslogger.php';
3333

3434
$_SESSION = [];
35-
xoops_setcookie('xo_install_user', '', null, null, null);
35+
xoops_setcookie('xo_install_user', '', 0, '', '');
3636
$key = \Xmf\Jwt\KeyFactory::build('install');
3737
$key->kill();
3838
defined('XOOPS_INSTALL') || die('XOOPS Installation wizard die');

htdocs/install/page_langselect.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
require_once __DIR__ . '/include/common.inc.php';
3030
defined('XOOPS_INSTALL') || die('XOOPS Installation wizard die');
3131

32-
xoops_setcookie('xo_install_lang', 'english', null, null, null);
32+
xoops_setcookie('xo_install_lang', 'english', 0, '', '');
3333
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_REQUEST['lang'])) {
3434
$lang = $_REQUEST['lang'];
35-
xoops_setcookie('xo_install_lang', $lang, null, null, null);
35+
xoops_setcookie('xo_install_lang', $lang, 0, '', '');
3636

3737
$wizard->redirectToPage('+1');
3838
exit();
3939
}
4040

4141
$_SESSION['settings'] = [];
42-
xoops_setcookie('xo_install_user', '', null, null, null);
42+
xoops_setcookie('xo_install_user', '', 0, '', '');
4343

4444
$pageHasForm = true;
4545
$title = LANGUAGE_SELECTION;

htdocs/install/page_tablesfill.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function xoops_loadLanguage($name, $domain = '', $language = null)
118118
];
119119
$token = \Xmf\Jwt\TokenFactory::build('install', $claims, 60 * 60);
120120

121-
xoops_setcookie('xo_install_user', $token, 0, null, null, null, true);
121+
xoops_setcookie('xo_install_user', $token, 0, '', '', null, true);
122122
}
123123

124124
include __DIR__ . '/include/install_tpl.php';

0 commit comments

Comments
 (0)