SessionUpdateTimestampHandlerInterface

SessionUpdateTimestampHandlerInterface allows session handlers to validate session IDs and control whether the session timestamp is updated on read.

It adds two methods: validateId(string $id): bool to check whether a session ID exists, and updateTimestamp(string $id, string $data): bool to refresh the session’s last-accessed time without rewriting all its data.

<?php

class OptimisedSessionHandler implements SessionHandlerInterface, SessionUpdateTimestampHandlerInterface {
    public function validateId(string $id): bool {
        return (bool) $this->redis->exists('sess:' . $id);
    }

    public function updateTimestamp(string $id, string $data): bool {
        return (bool) $this->redis->expire('sess:' . $id, 1440);
    }
    // ... implement remaining SessionHandlerInterface methods
}

?>

Documentation

See also SessionUpdateTimestampHandlerInterface Interface.

Related : Session, Interface, PHP Native Interfaces, SessionHandlerInterface, SplSubject

Added in PHP 7.0