In order to use sessions in PHP, you must log on first. We can do this by actually using the statement session_start(), or by recording a variable in one session using session_register('myVariable'). In both cases a new session is created if there is no session, or the current session is retaken. See a simple example:
This is the most basic form, if the user has enabled cookies, PHP will automatically insert the session and this will be run from one page to another without any further action. From a practical point of view, the session is operational but we do not see anything. We can get the session at any moment by using the statement session_id(). Insert the following row in the subsequent pages to see if the session is available:
In this case session_start() proves in the cookies that there is a session and continues with it, session_id() returns the current identifier.