Click to See Complete Forum and Search --> : how to destroy Session Element


rm_vk
05-25-2005, 02:05 AM
I have a text box called 'quantity' in my html form.
The value entered in that text box is appended to a session called 'sqty'.
It is done as follows.
$_SESSION['sqty']=$_SESSION['sqty'].",".$_POST['quantity'];

Every time the value I entered is appended to session.
It is working fine for adding or appending.

But my problem is that : I dont know how to remove particular element from session 'sqty'.
If I want to remove sixth element which appended to session 'sqty', how to destroy or delete from session.

Please reply to this

ShrineDesigns
05-25-2005, 03:25 AM
it would be easier to set $_SESSION['sqty'] as an array, that way you don't have to mess around with try to remove parts of a string, ex.<?php
function add_item($qty)
{
$_SESSION['sqty'][] = $qty;
}
function sub_item($id)
{
unset($_SESSION['sqty'][$id]);
}
?>