Skip to content

Conversation

@mambax7
Copy link
Collaborator

@mambax7 mambax7 commented Mar 15, 2025

PR#1511 introduced a new bug:

when calling: $GLOBALS['xoopsSecurity']->check(), it was returning error: 'No valid token found' because by calling session_write_close() in createToken(), the session is closed prematurely. When the script continues execution (e.g., during token validation), the session is no longer active, and attempts to access or modify $_SESSION fail or start a new session, resulting in the token not being found.

Commenting out session_write_close() keeps the session open, so $_SESSION remains accessible, and validateToken() should find the token without needing to restart the session.
As a safeguard, I've added in validateToken():

if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}

…y']->check()```

it was returning error:  'No valid token found' because by calling session_write_close() in createToken(), the session is closed prematurely. When the script continues execution (e.g., during token validation), the session is no longer active, and attempts to access or modify $_SESSION fail or start a new session, resulting in the token not being found.

Commenting out session_write_close() keeps the session open, so $_SESSION remains accessible, and validateToken() should find the token without needing to restart the session.

As a safeguard, I've added:
```php
if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start();
}
```
@mambax7 mambax7 changed the title PR#1511 introduced a new bug: when calling: ```$GLOBALS['xoopsSecurit… fix for new bug from PR#1511 Mar 15, 2025
@mambax7 mambax7 merged commit a102859 into XOOPS:master Mar 26, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant