Welcome Guest, Not a member yet? Register   Sign In
Question about CI_Session
#1

[eluser]korpirkor[/eluser]
Hi Smile
I'm doing my first project on CodeIgniter (and first with MVC at all) and I have question about Session library.

There is sess_update() method, which is updating last_activity and session_id after $config['sess_time_to_update'] seconds.

My question is: why are we creating new session_id each time ???

I have rewritten sess_update into MY_Session:
Code:
class MY_Session extends CI_Session
{
    function sess_update()
    {
        if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
            return;

        $this->userdata['last_activity'] = $this->now;
        $cookie_data = NULL;
        if ($this->sess_use_database === TRUE)
        {
            $cookie_data = array();
            foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
                $cookie_data[$val] = $this->userdata[$val];

            $this->CI->db->query($this->CI->db->update_string($this->sess_table_name, array('last_activity' => $this->now), array('session_id' => $this->userdata['session_id'] )));
        }
        $this->_set_cookie($cookie_data);
    }
}

Question 2. Can my code mess up something?


Messages In This Thread
Question about CI_Session - by El Forum - 08-24-2010, 02:47 PM
Question about CI_Session - by El Forum - 08-24-2010, 04:43 PM
Question about CI_Session - by El Forum - 08-25-2010, 08:02 AM
Question about CI_Session - by El Forum - 08-25-2010, 12:28 PM
Question about CI_Session - by El Forum - 08-25-2010, 02:39 PM
Question about CI_Session - by El Forum - 08-26-2010, 12:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB