PHP SESSIONS
- When you work with an application, you open it, do some changes, and then you close it.
- This is much like a Session.
- The computer knows who you are.
- It knows when you start the application and when you end.
- But on the internet there is one problem.
- The web server does not know who you are or what you do, because the HTTP address doesn't maintain state
- Session variables solve this problem by storing user information to be used across multiple pages.
DIFFERENT TYPES OF SESSIONS IN PHP :
- Budget session (February to May).
- Monsoon session (July to September).
- Winter session (November to December).
SYNTAX OF SESSIONS IN PHP :
session_start() function is used to begin a new session.
EXAMPLE FOR SESSIONS IN PHP :
<?php
session_start ( ) ;
echo ' The Name of the student is :' .$_SESSIONS[" Name "].'<br>';
echo ' The Roll number of the student is :' .$_SESSIONS[" Rollnumber "].'<br>';
session_start ( ) ;
echo ' The Name of the student is :' .$_SESSIONS[" Name "].'<br>';
echo ' The Roll number of the student is :' .$_SESSIONS[" Rollnumber "].'<br>';
?>
OUTPUT :
The Name of the student is : Rosa
The Roll number of the student is : 21