below is a php code that is used to add variables to a session.
<?php
session_start();
if(isset($_GET['name'])) {
$name = isset($_SESSION['name']) ? $_SESSION['name'] : array();
$name[] = $_GET['name'];
$_SESSION['name'] = $name;
}
if (isset($_POST['remove'])) {
unset($_SESSION['name']);
}
?>
<pre><?php print_r($_SESSION); ?></pre>
<form name="input" action="index.php?name=<?php echo $list ?>" method="post">
<input type="submit" name ="add"value="Add" />
</form>
<form name="input" action="index.php?name=<?php echo $list2 ?>" method="post">
<input type="submit" name="remove" value="Remove" />
</form>
i need to remove the variable that is shown in $list2 from the session array when the user wants to remove . But when i unset, all the variables in the array are deleted. Can some one please tell me how can i delete one variable?
Thanks