CodeIgniter Forums
Extending Drivers in 3.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Extending Drivers in 3.0 (/showthread.php?tid=196)



Extending Drivers in 3.0 - nnolting - 11-10-2014

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.


RE: Extending Drivers in 3.0 - slax0r - 11-11-2014

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?


RE: Extending Drivers in 3.0 - nnolting - 11-11-2014

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?