This article is about how PHP session works internally. Below are the steps : 1. Session in PHP is loaded into PHP core as an extension, we can understand it as an extension. When session extension is loaded, PHP will call core functions to get the session save_handler, i.e interface or functions for reading and writing session data. By default, PHP will handle session data by writing and reading files on the server. But PHP also supplies custom methods for handling session data, we can use session_set_save_handler() to register the save_handler. At the same time, PHP will check whether session_auto_start is on or off in the configuration file, if it is on, PHP will call internal functions to create session automatically.