Store multiple data in a session, you can store multiple times data in a PHP session without destroying previous session data.
Please find PHP method below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <?php public function recentSearch(){ $product_name = $this->input->post('product_name'); $product_price = $this->input->post('product_price'); $product_img = $this->input->post('product_img'); $product_url = $this->input->post('product_url'); $recentData = array( 'product_name' => $product_name, 'product_price' => $product_price, 'product_img' => $product_img, 'product_url' => $product_url ); if(count($_SESSION['arr'])==0) { $ar=array(); $val=$recentData; array_push($ar,$val); $_SESSION['arr']=$ar; //print_r($_SESSION['arr']); } else { $val=$recentData; array_push($_SESSION['arr'],$val); //print_r($_SESSION['arr']); } print_r($_SESSION['arr']); } ?> |