Hi

I'm having problems unsetting session varibles using this code. I'm not sure what I'm doing wrong. Nothing happens. Please help

<?php
session_start();

$id = $_GET['id'];
$pro = $_SESSION['products'];
$qua = $_SESSION['quantity'];

echo $pro[$id].''." Has been removed";

unset($pro[$id]);
 session_write_close();
unset($qua[$id]);
 session_write_close();


?>
Member Avatar for Zagga

Hi Que336,

$pro itself is not a session variable, it is just set to the same value as a session variable. Try using ... unset ($_SESSION['products']);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.