Welcome Guest, Not a member yet? Register   Sign In
Flashdata being cached
#1

[eluser]Daniel H[/eluser]
I'm experiencing a really frustrating problem with storing flash data with database caching on. It seems that session data is cached along with every other query, yet I obviously would never need this to be cached.

Can anyone recommend how I can stop session data being cached?

Dan.
#2

[eluser]Daniel H[/eluser]
Sorry to bump - has anybody experienced this problem before I raise a bug?
#3

[eluser]laxkin[/eluser]
[quote author="Daniel H" date="1227242983"]Sorry to bump - has anybody experienced this problem before I raise a bug?[/quote]

Yes, I have same problem. I was planning to write a standalone post but found that one. Smile

There is a BUG with DB caching and session flashdata.
The sequence(schematic) to reproduce this bug from my own project:
- uri: /admin/edit/articles
on this page request 'message' from session flashdata by session->flashdata('message')
as result executed sess_read() and this query is cached
An user can click the following url on the page: /admin/delete/article/<id>
- uri /admin/delete/article/<id>
sess->set_flashdata('message', 'bla-bla');
inside sess_write method executed there is a call of db->update (store 'message')
redirect to /admin/edit/articles (1st page)
- uri: /admin/edit/articles
sess_read() -> get cached data without 'message' Sad

WORKAROUND 1: extends CI_Session and wrap sess_read method as below
UPDATE: Create a new file MY_Session.php inside /aplication/library folder and copy/paste the following code:

Code:
&lt;?php
if (! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Session extends CI_Session
{

    function MY_Session()
    {
        parent::CI_Session();
    }

    function sess_read()
    {    
        // disable caching of session
        $this->CI->db->cache_off();
        $result = parent::sess_read();
        $this->CI->db->cache_on();
        return $result;
    }
}

WORKAROUND 2: Turn off the DB cache Smile

p.s. I hope this will help you to solve the problem.




Theme © iAndrew 2016 - Forum software by © MyBB