Example of session functions in PHP

Welcome, your session ID is 696da348674907098a3f310c868e2f4f


PHP code

In header of the file you start a session:
<?php
session_start();
?>
To destroy session you have to use two functions: session_destroy() together with session_start()
Example:
session_start();
session_destroy();
When you move on to other pages that work with a session, the session you have destroyed will not be available, but the variables will be still available to script that called session_destroy(). To make them unavailable you have to use session_unset() function.
Registering and accessing variables with session
Registering and accessing array variable with session


Back to main page