Codeigniter会话超时消息

I'm not new to CodeIgniter, but I'm not a pro either... still getting used to it, I suppose. I'm curious to see if anyone has any ideas as to how to display a message saying a session has timed out when the Session library kills an inactive session.

I've tried extending the Session.php library and adding:

// Is the session current?
    if (($session['last_activity'] + $this->sess_expiration) < $this->now)
    {
        $this->sess_destroy();
        $this->set_flashdata('timeout_message', "Session Timed Out."); // <--added
        return FALSE;
    }

But I think when FALSE is returned and my controller redirects to the page that will display the flash message.. the flash data is erased.

Any ideas?

I think you should just go about this a slightly different way. Assuming you have some sort of main controller that everything else inherits from in order to run some fundamentals then you could add a version of the method you have to that. Each time a user requests a new page you simply run the check above. If it fails you can destroy the current session (or run a log out method if you have one), start a new one, set the flashdata message and redirect back to the homepage or wherever you want. This will ofcourse start a new session but surely that's ok if the user has been logged out and all precious session data has been lost?