April 2026
Intermediate
1009 pages
34h 15m
English
Although PHP's session handling really has a good reputation, there are scenarios in which separate session management makes sense. Imagine, for example, that you want to collect data during a session and store it in a database; you also want the session itself to be kept in a database. In such cases, PHP allows you to take care of session data management yourself. The corresponding PHP function is called session_set_save_handler():
bool session_set_save_handler(callback open, callback close, callback read, callback write, callback destroy, callback gc)
The six parameters have the following meanings:
openOpen the session
closeClose the session
readRead session data
writeWrite session data
destroyDestroy ...
Read now
Unlock full access