session_set_save_handler

FunctionParams changed in PHP 8.3

Sets user-level session storage functions.

PHP 5
PHP 7.0
Improved
PHP 7.1-7.4
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

session_set_save_handler Function synopsis

session_set_save_handler(
    $open,
    $close = <default>,
    callable $read = <default>,
    callable $write = <default>,
    callable $destroy = <default>,
    callable $gc = <default>,
    ?callable $create_sid = null,
    ?callable $validate_sid = null,
    ?callable $update_timestamp = null
  ): bool

Parameters

$open

A callable with the following signature:

$close

OptionalDefault value

A callable with the following signature:

$read

OptionalTypecallableDefault value

A callable with the following signature:

$write

OptionalTypecallableDefault value

A callable with the following signature:

$destroy

OptionalTypecallableDefault value

A callable with the following signature:

$gc

OptionalTypecallableDefault value

A callable with the following signature:

$create_sid

OptionalType?callableDefault valuenull

A callable with the following signature:

$validate_sid

OptionalType?callableDefault valuenull

A callable with the following signature:

$update_timestamp

OptionalType?callableDefault valuenull

A callable with the following signature:

Return value

Typebool

Returns true on success, false on failure

Changes to the session_set_save_handler Function

PHP 8.3

  • Parameter type changed for parameter #7 ($create_sid): callable to ?callable
  • Parameter default value changed for position #7 ($create_sid): <default> to null
  • Parameter type changed for parameter #8 ($validate_sid): callable to ?callable
  • Parameter default value changed for position #8 ($validate_sid): <default> to null
  • Parameter type changed for parameter #9 ($update_timestamp): callable to ?callable
  • Parameter default value changed for position #9 ($update_timestamp): <default> to null
  session_set_save_handler(
      $open,
      $close = <default>,
      callable $read = <default>,
      callable $write = <default>,
      callable $destroy = <default>,
      callable $gc = <default>,
-     callable $create_sid = <default>,
+     ?callable $create_sid = null,
-     callable $validate_sid = <default>,
+     ?callable $validate_sid = null,
-     callable $update_timestamp = <default>
+     ?callable $update_timestamp = null
    ): bool

PHP 8.0

  • Return type added: bool
  • Parameter default value added for position #2 ($close): <default>
  • Parameter type added for parameter #3 ($read): callable
  • Parameter default value added for position #3 ($read): <default>
  • Parameter type added for parameter #4 ($write): callable
  • Parameter default value added for position #4 ($write): <default>
  • Parameter type added for parameter #5 ($destroy): callable
  • Parameter default value added for position #5 ($destroy): <default>
  • Parameter type added for parameter #6 ($gc): callable
  • Parameter default value added for position #6 ($gc): <default>
  • Parameter type added for parameter #7 ($create_sid): callable
  • Parameter default value added for position #7 ($create_sid): <default>
  • Parameter type added for parameter #8 ($validate_sid): callable
  • Parameter default value added for position #8 ($validate_sid): <default>
  • Parameter type added for parameter #9 ($update_timestamp): callable
  • Parameter default value added for position #9 ($update_timestamp): <default>
  session_set_save_handler(
      $open,
-     $close,
+     $close = <default>,
-     $read,
+     callable $read = <default>,
-     $write,
+     callable $write = <default>,
-     $destroy,
+     callable $destroy = <default>,
-     $gc,
+     callable $gc = <default>,
-     $create_sid,
+     callable $create_sid = <default>,
-     $validate_sid,
+     callable $validate_sid = <default>,
-     $update_timestamp
+     callable $update_timestamp = <default>
-   )
+   ): bool

PHP 7.0

  • Optional parameter added - #8: $validate_sid
  • Optional parameter added - #9: $update_timestamp
 session_set_save_handler(
     $open,
     $close,
     $read,
     $write,
     $destroy,
     $gc,
-    $create_sid
+    $create_sid,
+    $validate_sid,
+    $update_timestamp
   )

PHP 5.5

  • Optional parameter added - #7: $create_sid
 session_set_save_handler(
     $open,
     $close,
     $read,
     $write,
     $destroy,
-    $gc
+    $gc,
+    $create_sid
   )

session_set_save_handler Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes