2. What is session in PHP
PHP session is used to store and pass information from
one page to another temporarily (until user close the
website). PHP session technique is widely used in
shopping websites where we need to store and pass cart
information
3. Starting a Session
in PHP use the session start();
his method starts a new session or returns to an
existing one
<?Php session_start();
4. Storing Data in session
After starting a session, you may utilize the
$_SESSION global variable to save data in the
session
<?Php session_start();
$_SESSION['username'] = “samih";
5. Retrieving Data in session
To retrieve data from a session you can use the $_SESSION global variable
and access the key of the data that you want to retrieve
<?php session_start();
echo $_SESSION['username’];
// will output “samih"
8. Deleting Data
To delete data from a session, you can unset
the key of the data that you want to remove.
Here’s an example of deleting data from a
session:
<?php session_start();
unset($_SESSION['username']);