Merge pull request #54776 from nextcloud/backport/54713/stable31

[stable31] fix(status.php): Fix samesite cookies
pull/54808/head
Andy Scherzinger 2025-09-02 13:57:22 +07:00 committed by GitHub
commit 4948a742de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 4 deletions

@ -387,17 +387,18 @@ class OC {
// prevents javascript from accessing php session cookies
ini_set('session.cookie_httponly', 'true');
// set the cookie path to the Nextcloud directory
$cookie_path = OC::$WEBROOT ? : '/';
ini_set('session.cookie_path', $cookie_path);
// Do not initialize sessions for 'status.php' requests
// Monitoring endpoints can quickly flood session handlers
// and 'status.php' doesn't require sessions anyway
// We still need to run the ini_set above so that same-site cookies use the correct configuration.
if (str_ends_with($request->getScriptName(), '/status.php')) {
return;
}
// set the cookie path to the Nextcloud directory
$cookie_path = OC::$WEBROOT ? : '/';
ini_set('session.cookie_path', $cookie_path);
// Let the session name be changed in the initSession Hook
$sessionName = OC_Util::getInstanceId();