php - How to keep a session alive after logging in (Codeigniter) -
we building webshop based on codeigniter. products saved in shopping cart of codeigniters' cart class.
when visitor logs in it's account, products in cart removed because new session started when user logged in.
how can keep products in cart @ point?
if($query->num_rows() == 1) { $user = $query->row_array(); $data = array( 'userid' => $user['id'], 'email' => $user['email'], 'validated' => true ); $this->session->set_userdata($data); return true; }
you have create new table in base, shoppingcarts, , pass items chart class in table, , user id, when user log in query table id , id of row got products.but when user bye delete rows in base , unset cart class
$data = array( 'id' => 'sku_123abc', 'qty' => 1, 'price' => 39.95, 'name' => 't-shirt', 'options' => array('size' => 'l', 'color' => 'red' 'user_id => '45') ); $this->cart->insert($data); $chart = $this->cart->contents(); $this->db->insert('shoppingcarts',$chart);
this simple example, how :)
Comments
Post a Comment