PHP / PHP Sessions
Session is a used to store single user information across multiple pages using session variables which are not stored on the users computer.
Start a PHP Session
A session is started with the session_start() function and session variables are set with the PHP global variable with $_SESSION. Write a program to store session information and retrieve it. Here PHP session session variables: Lang and LangType.
sessionstart.php() |
Retrievesessioninfo.php |
|
|
Output
Session variables are stored / set.
|
Output
Language: PHP.
Language: ServerSide.
|
Destroy a PHP Session
To remove all session information use session_unset(); , session_destroy(); functions.
Function Name |
Purpose |
session_unset(); |
remove all session information / variables |
session_destroy(); |
destroy the session |
Program |
Output |
|
All Sessions are destroyed.
|
|