I am developing a website (with a shopping cart) on top of Codeigniter and want to use the sess_use_database parameter to make it difficult for users to hack into the shopping cart session.
I also want to use database caching to speed up common database queries (for example, βget categoriesβ, since most of the contents of the database will not change regularly), so I turned on this option:
$db['development']['cache_on'] = TRUE; //where 'development' is my environment
As a result, I found that the contents of the session are not being updated, for example, with this request:
$this->basket_contents = array_values($this->session->userdata('basket_contents'));
Also, I tried this:
$this->db->cache_off();
... before requesting a session, but it does not solve the problem (I assume, because this is not a direct DB request).
My session settings are as follows:
$config['sess_cookie_name'] = 'str_session'; $config['sess_expiration'] = 7200; $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;
Is it possible to prevent caching of session-related database queries? Or to prohibit caching of certain tables?
OR is there another (possibly obvious) solution that I haven't thought about?
Thanks in advance.
php caching session-cookies codeigniter
Ade
source share