开发者

why lost data in session?

开发者 https://www.devze.com 2022-12-21 06:44 出处:网络
data lost when passing session to array and using foreach(looping). qty lost is the text f开发者_Go百科rom another page why lost this????

data lost when passing session to array and using foreach(looping). qty lost is the text f开发者_Go百科rom another page why lost this???? using looping to delete item by id from get (using link in another page)

$cart = $_SESSION['cart'];

$id = $_GET['id'];

$arrcart = array();

$count=0;
    $qty = intval($_POST['product_'.$product['product_id']]);

if($id)
{
foreach($cart as $keys)
{
if($id != $keys['product_id'])
{
        $arrcart[$count]=array('qty' => $qty,
                            'product_id' => $keys['product_id'],    
                            "name" => $keys['name'], 
                            "description" => $keys['description'],
                            "price" => $keys['price'],
                            "total" => $keys['price']*$qty
                            );
}
        $count++;
}`enter code here`
$_SESSION['cart']=$arrcart;
}
</code>


Looking at your code and taking a stab in the dark, I don't see session_start() anywhere. Try putting this at the top of your PHP code:

session_start();
0

精彩评论

暂无评论...
验证码 换一张
取 消