<?php

error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);      //all error but warnigns & notices

$option   = $_GET['option'];
$varName  = $_POST['varName'];  
$varValue = $_POST['varValue'];  

//ini_set('session.use_trans_sid', true);       #in case it is not set in the php.ini file
session_start();                                #start a session

if ($option =='add')                            #add item to the $_SESSION array
    $_SESSION[$varName] = $varValue;

if ($option =='del')                            #delete item from $_SESSION array
    unset($_SESSION[$varName]);
?>                          

<html>
<head>
<title>Session Variables List</title>
</head>

<body bgcolor=lightyellow>
<h1>Create and Read Session Variables</h1>

<h2>Your Session variables Are:</h2>

<table border=2 bgcolor=tan>
<tr bgcolor=cccccc><th><i>Variable Name<th><i>Variable Value</th>

<?php
        
    foreach ($_SESSION as $name => $value)                      //loop through $_SESSION array
        print  "<tr><td><b>$name<td>$value</td></tr> \n";       //print variable name & value

    print "</table>";
    
    if (!$_SESSION)
        print "<h4>There are no session variables</h4>"; 
?>

<?php include "../include.php"; ?>      <!-- hyperlink to see the code -->
</body>
</html>