Welcome Guest, Not a member yet? Register   Sign In
Extending Drivers in 3.0
#1

Is is possible to extend drivers in CI 3 as you would extend libraries in CI 2.x with the MY_ prefix?

For Instance i'm trying to extend the CI_Session_cookie library with a override to _sess_update so that ajax requests won't jack with the current user session.

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

require_once SYSDIR . '/libraries/Driver.php';
require_once SYSDIR . '/libraries/Session/Session.php';
require_once SYSDIR . '/libraries/Session/drivers/Session_cookie.php';

class MY_Session_cookie extends CI_Session_cookie
{

    public function __construct()
    {
        parent::__construct();
        log_message('info', 'MY_Session_cookie loaded');
    }

    protected function _sess_update($force = false)
    {

        // Do NOT update an existing session on AJAX calls.
        if ($force || !$this->CI->input->is_ajax_request())
            return parent::_sess_update($force);
    }

}

/* End of file MY_Session_cookie.php */
/* Location: ./application/libraries/Session/MY_Session_cookie.php */

I can't tell if it's been loaded since the 'MY_Session_cookie loaded' message is not being written to the log.
Reply
#2

Session_cookie.php is located in system/libraries/Session/drivers/, your last line comment, "Location" points to application/libraries/Session/, are you missing a subdir "drivers"? Or is it just a mistake in the comment? And I assume logging is turned on? And configured to log at least INFO level?
Reply
#3

That was it, I had to move it into the drivers folder, thanks.

(11-11-2014, 07:18 AM)slax0r Wrote: Session_cookie.php is located in system/libraries/Session/drivers/, your last line comment, "Location" points to application/libraries/Session/, are you missing a subdir "drivers"? Or is it just a mistake in the comment? And I assume logging is turned on? And configured to log at least INFO level?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB