php - CodeIgniter Shopping Cart Strange Behaviour -


i have strange behaviour of codeigniter's shopping cart class. have set ci_session table in database , have changed sess_use_database true.

what happening when add items shopping cart fine: see total items counter going , everything. when go shopping cart page first time see items there, should be. have provided delete item button , empty cart button. strange things happen here: when click remove item, page refreshes (due redirect think) item still there! if manually refresh page of cart, see same item had removed disappear. it's like, when use redirect, cache of page, not actual page fresh information on it.

anyway, here links:

try add items page: http://www.pantanishoes.it/niko/index.php/store/linea/urban clicking on big dark button on bottom of every item description.

then try go carrello on menu on top , try delete of items or svuota(which simple destroy()) , see happens! appreciated! in advice!

here code of cart.

function add() {      $item = $this->store_model->get_item($this->input->post('id'));      $data = array(         'id' => $this->input->post('id'),         'name' => $item->modello,         'qty' => $this->input->post('qty'),         'price' => $item->prezzo,         'options' => array(             'taglia' => $this->input->post('taglia'),             'linea' => $item->linea,             'modello' => $item->modello,             'foto' => $item->foto1             )     );      $this->cart->insert($data);      $linea = str_replace(' ', '-', $item->linea);      redirect('/store/linea/' . $linea . '/', 'location'); }  function remove() {     $rowid = $this->uri->segment(3);     $data = array(         'rowid' => $rowid,         'qty' => 0     );      $this->cart->update($data);     redirect('cart'); }  function destroy() {     $this->cart->destroy();     redirect('cart'); } 

on localhost working great! when loaded website server, started have issues. really strange! there config thing i'm missing?

chrome says: request url:http://www.pantanishoes.it/niko/index.php/cart/remove/fb1b4a9869de6f24aa620e2307192d93 request method:get status code:302 moved temporarily (from cache)

ok guys. fixed little bug of friend of mine has used ci while. of guessed, cache problem. thing need force php headers so:

header( 'expires: sat, 26 jul 1997 05:00:00 gmt' );  header( 'last-modified: ' . gmdate( 'd, d m y h:i:s' ) . ' gmt' );  header( 'cache-control: no-store, no-cache, must-revalidate' );  header( 'cache-control: post-check=0, pre-check=0', false );  header( 'pragma: no-cache' ); 

you can private function in controller it's not accessible outside , call in relative add, delete, destroy methods. private function must this:

private function _set_headers() {     header( 'expires: sat, 26 jul 1997 05:00:00 gmt' );      header( 'last-modified: ' . gmdate( 'd, d m y h:i(worry)' ) . ' gmt' );      header( 'cache-control: no-store, no-cache, must-revalidate' );      header( 'cache-control: post-check=0, pre-check=0', false );      header( 'pragma: no-cache' ); } 

and call inside other functions so:

$this->_set_headers(); 

remember work in scope of class. can't call function in other controllers , can't accessed outside scope, cause it's not public.

thanks all!!


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -