Deleting Sessions in PHP
Sometimes we may need to delete a specific
session variable without affecting the others.
This is done using the unset function:
<?php
unset($_SESSION['var']);
?>
After executing such code, our variable
will become null:
<?php
var_dump($_SESSION['var'); // will output null
?>
Here is the counter code from the previous lesson:
<?php
session_start();
if (!isset($_SESSION['counter'])) {
$_SESSION['counter'] = 1;
} else {
$_SESSION['counter']++;
}
echo $_SESSION['counter'];
?>
Modify this code so that when the counter reaches
the value of 10, the count starts
over.