index.php
<?php
session_start();
$_SESSION['user']='tom';
$role = "admin";
session_register('role');
?>
<html>
<body>
Created session variables are:
user='<?=$_SESSION['user']?>' and role='<?=$_SESSION['role']?>'<br><br>
<?='<a href="print.php">Check if session variables are saved</a>';?>
<br><br>
Session ID is: <?= session_id(); ?>
</body>
</html>
print.php
<?php
session_start();
if (isset($_GET['delete'])) {
session_unset();
//$_SESSION = array();
session_destroy();
}
?>
<html>
<body>
Saved session variables are:<br><br>
user:<?=$_SESSION['user'];?><br>
role:<?=$_SESSION['role'];?>
<br><br>
Session ID is: <?= session_id(); ?><br><br>
<a href="?delete=1">Delete session</a><br><br>
<a href="index.php">Go back</a>
</body>
</html>
The screenshots are:index.php:
print.php:
After clicking 'Delete session':