Skip to content

fix(builtin): persist sess files with custom save handler#10

Merged
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/persist_sess_files_custom_handler
Jun 11, 2026
Merged

fix(builtin): persist sess files with custom save handler#10
ralflang merged 1 commit into
FRAMEWORK_6_0from
fix/persist_sess_files_custom_handler

Conversation

@TDannhauer

Copy link
Copy Markdown
Contributor

Fix BuiltinBackend session persistence with modern save handler

Summary

  • Implement BuiltinBackend::save() to write PHP's default sess_<id> session files

Problem

Horde registers Horde\SessionHandler\SessionHandler via session_set_save_handler().
With sessionhandler.type = builtin, PHP calls SessionHandler::write(), which delegates
to BuiltinBackend::save().

BuiltinBackend::save() was a no-op, with a comment assuming PHP's native handler would
still write files. That is no longer true once a custom save handler is installed.

Symptom: Login via login.php appeared to succeed (no error message), but the next
request loaded an empty session and redirected back to the login form.

Within a single request, auth lived only in memory; nothing was persisted to disk.

Solution

Write the serialized session blob to sess_<id> under the configured save path (same
layout load() already reads). Throw RuntimeException if the write fails, matching
FileBackend behaviour.

Test plan

  • Configure sessionhandler.type = Builtin in a Horde deployment
  • Log in via classic login.php with valid credentials
  • Confirm the portal (or initial page) loads on the following request without returning to login
  • Confirm a sess_<session_id> file exists under PHP's session save path after login

Related

  • Horde Core session shim mirrors HordeSession data into $_SESSION before PHP's save
    handler runs; this fix ensures that mirrored payload is actually written when the
    builtin backend is selected.

BuiltinBackend::save() was a no-op, assuming PHP's native handler would
still write session files. Once SessionHandler is registered via
session_set_save_handler(), PHP only calls the backend save path.

Without writing sess_<id> files, login worked in-memory for the current
request but the next request loaded an empty session, causing a silent
login loop back to login.php.

Add BuiltinBackendTest covering save/load roundtrip.
@TDannhauer TDannhauer requested a review from ralflang June 10, 2026 20:46
@ralflang

Copy link
Copy Markdown
Member

no, this is solved by installing the session_handler shim as a shutdown task.

@ralflang ralflang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will accept and then rework this. This claims to be interoperable with PHP Builtin sessions but isn't - it's the Files backend in disguise.

@ralflang ralflang merged commit 6b54ed8 into FRAMEWORK_6_0 Jun 11, 2026
0 of 6 checks passed
ralflang added a commit that referenced this pull request Jun 11, 2026
…essionhandler

This expands on #10 which was incompatible with PHP's original sessionhandler
Now Horde's "BuiltinBackend" can read and write session files originally created by PHP's real "builtin" sessionhandler

Adheres to session.save_path ini setting
Does not auto-create subdirectories but throws exception if missing

Still deviates in the way we handle locking and atomic writes
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