PHP 7 Session Options
In PHP 7, the session_start() function can accept an array as a parameter, which can override the session configuration items in php.ini.
This feature also introduced a new php.ini setting (session.lazy_write), which is set to true by default, meaning session data is only written when changes occur.
In addition to the regular session configuration directives, you can also include the read_and_close option in this array. If this option is set to TRUE, the session file will be closed immediately after reading is complete. Therefore, when session data has not changed, unnecessary file locking can be avoided.
Examples
Set cache_limiter to private, and close the session immediately after reading it.
Examples
session_start([
'cache_limiter' => 'private',
'read_and_close' => true,
]);
Other Extensions
PHP 7 New Features