Welcome Guest, Not a member yet? Register   Sign In
Extending the Session Library - I need to specify database to store sessions in.
#2

[eluser]danmontgomery[/eluser]
Couple of things here...

When you pass TRUE as the 2nd parameter, the DB object gets returned, not assigned to $CI->db. You would need to assign that DB object to something.

Code:
$this->sess_db = $this->CI->load->database($this->database_name, TRUE);

Then, you'd need to do work in pretty much every method in the session class, and replace calls to $this->CI->db with whatever class member you assigned your session db to. sess_read(), sess_write(), etc.

Code:
/**
     * Destroy the current session
     *
     * @access    public
     * @return    void
     */
    function sess_destroy()
    {
        // Kill the session DB row
        if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
        {
            $this->sess_db->where('session_id', $this->userdata['session_id']);
            $this->sess_db->delete($this->sess_table_name);
        }

        // Kill the cookie
        setcookie(
                    $this->sess_cookie_name,
                    addslashes(serialize(array())),
                    ($this->now - 31500000),
                    $this->cookie_path,
                    $this->cookie_domain,
                    0
                );
    }

etc.


Messages In This Thread
Extending the Session Library - I need to specify database to store sessions in. - by El Forum - 03-03-2011, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB