Skip to content

feat(serializer): pure-PHP session-data serializer#12

Merged
ralflang merged 1 commit into
FRAMEWORK_6_0from
feat/php-text-format-serializer
Jun 11, 2026
Merged

feat(serializer): pure-PHP session-data serializer#12
ralflang merged 1 commit into
FRAMEWORK_6_0from
feat/php-text-format-serializer

Conversation

@ralflang

Copy link
Copy Markdown
Member

NativePhpSessionSerializer wraps session_encode and session_decode.
Both functions only operate on the active PHP session via the session
module. Modern PSR-15 routes that own their session lifecycle through
SessionLifecycle and middleware never call session_start, so the
native serializer cannot read or write rows for them.

PhpTextSessionSerializer implements PHP's default php
session.serialize_handler format directly. Layout is a flat
concatenation of |<serialize($value)> records. Reader uses the
re-serialize-and-measure trick to advance past each record because
unserialize does not report bytes consumed.

DefaultSessionSerializer dispatches to PhpTextSessionSerializer for
session.serialize_handler=php and to PhpSessionSerializer for
php_serialize. Other handlers (igbinary, custom) raise a clear error
at construction. The handler is captured at construction time and
frozen, matching how PHP's session module reads the ini once on open.

Both formats produce the exact byte sequence that PHP's session
module produces on the same payload, so legacy callers that go
through session_start continue to read and write the same on-disk
rows. Modern and legacy stacks share storage.

NativePhpSessionSerializer wraps session_encode and session_decode.
Both functions only operate on the active PHP session via the session
module. Modern PSR-15 routes that own their session lifecycle through
SessionLifecycle and middleware never call session_start, so the
native serializer cannot read or write rows for them.

PhpTextSessionSerializer implements PHP's default php
session.serialize_handler format directly. Layout is a flat
concatenation of <key>|<serialize($value)> records. Reader uses the
re-serialize-and-measure trick to advance past each record because
unserialize does not report bytes consumed.

DefaultSessionSerializer dispatches to PhpTextSessionSerializer for
session.serialize_handler=php and to PhpSessionSerializer for
php_serialize. Other handlers (igbinary, custom) raise a clear error
at construction. The handler is captured at construction time and
frozen, matching how PHP's session module reads the ini once on open.

Both formats produce the exact byte sequence that PHP's session
module produces on the same payload, so legacy callers that go
through session_start continue to read and write the same on-disk
rows. Modern and legacy stacks share storage.
@ralflang ralflang merged commit e170416 into FRAMEWORK_6_0 Jun 11, 2026
0 of 6 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