Search Webmaster Help and Solution

[RESOLVED] remove item from session array

hi
i have a simple script that adds an item id to a session...

<?php
session_start();

$itemid = $_POST["itemid"];

if (count($_SESSION["cart"]) < 1) {
$_SESSION["cartitems"] = array();
}


$_SESSION["cart"][] = $itemid;


header("location:cart.php");
?>


i need something that will delete an id out of the array so the cart wont display this.

this is what i tried but nothing was change but no errors occured,

<?php
session_start();

$id=$_POST["id"];

unset($_SESSION[cart][$id]);


header("location:cart.php");

?>


i would be gratefull of any help,
many thanks hi
i have a simple script that adds an item id to a session...

<?php
session_start();

$itemid = $_POST["itemid"];

if (count($_SESSION["cart"]) < 1) {
$_SESSION["cartitems"] = array();
}


$_SESSION["cart"][] = $itemid;


header("location:cart.php");
?>


i need something that will delete an id out of the array so the cart wont display this.

this is what i tried but nothing was change but no errors occured,

<?php
session_start();

$id=$_POST["id"];

unset($_SESSION[cart][$id]);


header("location:cart.php");

?>


i would be gratefull of any help,
many thanks

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).