CodeIgniter Forums
Cart shows content only sometimes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Cart shows content only sometimes (/thread-53605.html)



Cart shows content only sometimes - El Forum - 07-31-2012

[eluser]Unknown[/eluser]
I have huge problem with cart library of codeigniter. It seems that it shows content only sometimes. I don't know why.

When I insert new item to cart content in insert_to_cart page and call var_dump($this->cart->content()) - it show entire cart content. Everything is ok.

Problem starts when i call var_dump($this->cart->contents()); in index, for example. It don't show content of cart at all, it shows zero, empty array... But if I call it again in insert_to_cart page, than content is untouched.

Some other informations from config.php

Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

Please, help.


Cart shows content only sometimes - El Forum - 08-10-2012

[eluser]srpurdy[/eluser]
[quote author="Smokie" date="1343747142"]I have huge problem with cart library of codeigniter. It seems that it shows content only sometimes. I don't know why.

When I insert new item to cart content in insert_to_cart page and call var_dump($this->cart->content()) - it show entire cart content. Everything is ok.

Problem starts when i call var_dump($this->cart->contents()); in index, for example. It don't show content of cart at all, it shows zero, empty array... But if I call it again in insert_to_cart page, than content is untouched.

Some other informations from config.php

Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

Please, help.[/quote]

Try This instead.

Code:
$config['sess_cookie_name']  = 'cisession';
$config['sess_expiration']  = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'ci_sessions';
$config['sess_match_ip']  = FALSE;
$config['sess_match_useragent'] = FALSE;
$config['sess_time_to_update'] = 300;

I also had issues with useragent match being on. I think that's where the problem is, but encrypt cookie imo should always be on also. Tongue