joyce
Wed 28th Aug '02, 9:21pm
hi, i'm working on a shopping cart. i store the necesary field in session and pass it to user cart when user add the item to cart.
i do not know how to delete a session, for eg, if user adds 3 items in the cart and he wants to delete one of the item, how can i delete just one of the id instead of all the ids...
this is how i store my session:
if (isset($HTTP_POST_VARS['pid']['pid']))
{
if (is_array($_SESSION['pid']))
{
if (!in_array($HTTP_POST_VARS['pid']['pid'], $_SESSION['pid']))
{
$_SESSION['pid'][] = $HTTP_POST_VARS['pid']['pid'];
}
}else
{
$_SESSION['pid'][] = $HTTP_POST_VARS['pid']['pid'];
}
}
this is the checkbox:
print "<td width=5%><input type=checkbox name=cb[] value=\"$i\"></td>\n";
and this, when user check the checkbox and click delete:
for ($i=0; $i<count($cb); $i++)
{
unset( $_SESSION['pid'][$cb[$i]] );
}
if i have 2 or more records, and i click the first record to be deleted, it will delete all the records i have it there.
pls advice!!
i do not know how to delete a session, for eg, if user adds 3 items in the cart and he wants to delete one of the item, how can i delete just one of the id instead of all the ids...
this is how i store my session:
if (isset($HTTP_POST_VARS['pid']['pid']))
{
if (is_array($_SESSION['pid']))
{
if (!in_array($HTTP_POST_VARS['pid']['pid'], $_SESSION['pid']))
{
$_SESSION['pid'][] = $HTTP_POST_VARS['pid']['pid'];
}
}else
{
$_SESSION['pid'][] = $HTTP_POST_VARS['pid']['pid'];
}
}
this is the checkbox:
print "<td width=5%><input type=checkbox name=cb[] value=\"$i\"></td>\n";
and this, when user check the checkbox and click delete:
for ($i=0; $i<count($cb); $i++)
{
unset( $_SESSION['pid'][$cb[$i]] );
}
if i have 2 or more records, and i click the first record to be deleted, it will delete all the records i have it there.
pls advice!!