php - My $_GET value is not getting stored in $_SESSION array -


i have script works cart-mechanism. want store $_get value in $_session array made , stores once. other indexes not getting added.

here code:

 <?php  session_start();    require_once 'db_connect.php';   $_session['product_name']=array ();  array_push($_session['product_name'],$_get["p_name"]);  ?> 

you unset $_session['product_name'] every time line:

$_session['product_name']=array (); 

change below:

if(!isset($_session['product_name'])     $_session['product_name']=array (); 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -