Visitar URL original
Prevent creating a new session until necessary by jornane · Pull Request #2685 · simplesamlphp/simplesamlphp · GitHub
Skip to content

Prevent creating a new session until necessary - #2685

Open
jornane wants to merge 4 commits into
simplesamlphp:masterfrom
jornane:fix/no-new-session
Open

jornane wants to merge 4 commits into
simplesamlphp:masterfrom
jornane:fix/no-new-session

Conversation

@jornane

@jornane jornane commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Fix for #2684

Make $session in Auth\Simple nullable, and add getSession() function that will load the session if it was not set. Informative actions such as checking if the user is logged in will null check the session, and not call the function, to avoid starting a session. Actions that have side effects, such as redirecting to login, will use the function and thus start a session.

Split Session::getExistingSessionFromRequest from Session::getSessionFromRequest, to allow retrieving a session only if it already exists, but avoid creating one if one doesn't exist already.

Make $session in Auth\Simple nullable, and add getSession() function
that will load the session if it was not set.  Informative actions
such as checking if the user is logged in will null check the session,
and not call the function, to avoid starting a session.  Actions that
have side effects, such as redirecting to login, will use the function
and thus start a session.

Add $canCreate argument to Session::getSessionFromRequest, to allow
retrieving a session only if it already exists, but avoid creating one
if one doesn't exist already.
Split getSessionFromRequest into two functions, one that will create
a new session if one does not exist, and one that will return null if
a session does not exist.

This allows different functions to have separate `@return` signatures.
@tvdijen
tvdijen requested a review from monkeyiq September 17, 2026 20:57
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.

2 participants