# `session_start()`

> Section in “New and Extended Functionality › Session Management” of the book [PHP 7 Explained](https://php7explained.com/) by Sebastian Bergmann and Stefan Priebsch, published by thePHP.cc. The book covers PHP 7.0 to 7.4 and was last updated in November 2020. HTML version: <https://php7explained.com/new-and-extended-functionality/session-management/session_start/>

Since HTTP is a stateless protocol, PHP has built-in support for sessions to maintain state between multiple requests. A new session was and is either automatically started when PHP is configured to autostart sessions upon request start or manually by calling `session_start()`.

Starting with PHP 7, `session_start()` accepts a configuration array to allow overwriting any previously configured ini setting that deals with the session subsystem.

Additionally, a new runtime only option can be included into this configuration array: `read_and_close`. If set to `true`, this option will result in the session being closed immediately after it was read. This avoids unnecessary locking in case the session data does not need to be changed during this request – for instance during an HTTP GET request – and enables multiple concurrent processes to read the session information at the same time. To ensure consistency of the data contained within the sesison in this mode, any modification to `$_SESSION` is silently discared at the end of the request.

---

Previous: [Session Management](https://php7explained.com/new-and-extended-functionality/session-management/index.html.md) | Next: [Session ID without Hashing](https://php7explained.com/new-and-extended-functionality/session-management/session-id-without-hashing/index.html.md)
