Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter – how to avoid database caching for sessions
    text
    copied!<p>I'm developing a website (with a shopping cart) on top of Codeigniter, and want to use the <strong>sess_use_database</strong> setting to make it more difficult for users to hack a shopping cart session.</p> <p>I also want to use database caching to speed up common DB requests (such as 'get categories' as most of the DB content won't change regularly), so I have enabled this setting:</p> <pre><code>$db['development']['cache_on'] = TRUE; //where 'development' is my environment </code></pre> <p>As a result, I am finding that session contents aren't being refreshed, for example on this request:</p> <pre><code>$this-&gt;basket_contents = array_values($this-&gt;session-&gt;userdata('basket_contents')); </code></pre> <p>Also, I have tried this:</p> <pre><code>$this-&gt;db-&gt;cache_off(); </code></pre> <p>...before the session request, but it doesn't solve the problem (I assume because it isn't a direct DB request).</p> <p>My session setings are as follows:</p> <pre><code>$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; </code></pre> <p>Can I prevent caching of session-related DB requests? Or prevent certain tables from being cached?</p> <p>OR is there another (probably obvious) solution I've not thought of?</p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload