Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/Storage/BuiltinBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,23 @@ public function load(SessionId $id): ?SerializedSessionPayload
}

/**
* No-op: PHP's built-in session handler writes the data natively.
* Persist session data to PHP's default sess_ file layout.
*
* When Horde registers {@see \Horde\SessionHandler\SessionHandler} as
* PHP's save handler, this backend must write the blob itself — PHP no
* longer invokes the native handler directly.
*/
public function save(SessionId $id, SerializedSessionPayload $payload, DateTimeImmutable $expiresAt): void {}
public function save(SessionId $id, SerializedSessionPayload $payload, DateTimeImmutable $expiresAt): void
{
$file = $this->filePath($id);
$written = @file_put_contents($file, $payload->getData(), LOCK_EX);

if ($written === false) {
throw new \RuntimeException(
sprintf('Failed to write session file "%s"', $file)
);
}
}

public function delete(SessionId $id): void
{
Expand Down
Loading