How to increment a value to a session?

0

I'm wanting to add a value to a session via GET. I'm doing it this way but it does not work.

function addCart($product){         
  $cart['cart'][$product] = 0;
  $_SESSION[] = $cart;
}
    
asked by anonymous 29.10.2015 / 14:37

1 answer

1

Example:

function addCart($product){
    session_start();
    $_SESSION['cart'][] = $product;
}

Do not forget to use session_start() , it may be out of function at the beginning of the body of the PHP document.

References:

link link link link

    
29.10.2015 / 14:50