Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated

Description

session_set_save_handler() used to accept six to to nine distinct callables to configure the handler. In fact, that PHP native function was available even before PHP had objects support.

Nowadays, there still needs that many callables, but they are expected to be grouped in a class, and checked by the SessionHandlerInterface interface.

Example

<?php

 session_set_save_handler(
    session_open(...),
    session_close(...),
    session_read(...),
    session_write(...),
    session_destroy(...),
    session_gc(...),
    session_create_sid(...),
    session_validate_sid(...),
    session_update_timestamp(...)
);

?>

Solutions

  • Refactor the callables into a class, add the SessionHandlerInterface implementation and use that class.