Welcome Guest, Not a member yet? Register   Sign In
CI 3.x extending Session class, _parent not set
#1

I have extended the session class as follows:

PHP Code:
require_once(BASEPATH 'libraries/Driver.php');
require_once(
BASEPATH 'libraries/Session/Session.php');
require_once(
BASEPATH 'libraries/Session/drivers/Session_cookie.php');

class 
CodeIgniterSession extends CI_Session_cookie 

I load the session driver with
PHP Code:
$this->load->driver('tho/CodeIgniter/CodeIgniterSession'); 
and right after I try to remove userdata with
PHP Code:
$this->codeignitersession->unset_userdata('order_code'); 

However, this gives me the error
Quote:Fatal error: Call to a member function select_driver() on a non-object in /home/tho/Projects/Webdesign/Codeigniter 3 system/libraries/Session/Session.php on line 703

On line 703, there is the code
PHP Code:
$this->_parent->select_driver(get_class($this)); 
and it seems that _parent is NULL. I figured out that _parent is set through decorate(), but I couldn't figure out so far when decorate is/should be called. Adding a simple echo into the decorate function did not give me any output, which makes it seems that decorate is never called...

A bug? Or am I doing something wrong?
Reply
#2

The Session class will be swapped with a new one, as far as I know. When this happens all you try here will get broken.
Reply
#3

@ivantcholakov: Thanks for the warning. I don't have too much in my extended session class so it should be easy to modify (hopefully)
@Mohammadhzp: I could not find much about extending drivers. CI2 has very little information, and neither does CI3. Found some more on stackoverflow...

I decided to just use the CI2 Session library for now and extend it as I have done it when using CI2. I will have to look into the CI3 session driver once it is more mature I guess.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB