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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -