title: How to remove a variable from a PHP session array
body: <p>I have PHP code that is used to add variables to a session:</p>
  
  <pre><code>&lt;?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']);
      }
  ?&gt;
  &lt;pre&gt;  &lt;?php print_r($_SESSION); ?&gt;  &lt;/pre&gt;
  
  &lt;form name="input" action="index.php?name=&lt;?php echo $list ?&gt;" method="post"&gt;
    &lt;input type="submit" name ="add"value="Add" /&gt;
  &lt;/form&gt;
  
  &lt;form name="input" action="index.php?name=&lt;?php echo $list2 ?&gt;" method="post"&gt;
    &lt;input type="submit" name="remove" value="Remove" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I want to remove the variable that is shown in <code>$list2</code> from the session array when the user chooses 'Remove'. </p>
  
  <p>But when I unset, ALL the variables in the array are deleted.</p>
  
  <p>How I can delete just one variable?</p>