April 2026
Intermediate
1009 pages
34h 15m
English
In contrast to programming with cookies, working with sessions is very easy. Although there are some functions for session management, most of the time the programming effort is limited to reading and writing the $_SESSION superglobal array.
Two steps are necessary to store data in the session:
Start session management with session_start(), if not already done (e.g., by setting session.auto_start = 1 in php.ini).
Write the data in $_SESSION.
As cookies may be used, you must start the session management before sending HTML to the client, so call session_start() in the header of the page. The data can be written anywhere on the page, however, as only the session ID is sent to ...
Read now
Unlock full access