[eluser]taig[/eluser]
Hi all,
I've written my own Session-Class (replaced the existing one - didn't extend). During the program flow there are several set_userdata()-functions executed (just like the original CI_Session-Class). Later on my post_system-hook is supposed to launch the method transmit_data() bundling all updates into one query.
The first issue I came across is that I'm not able to use the hook like this:
Code:
$hook['post_system'] = array(
'class' => 'Session',
'function' => 'transmit_data',
'filename' => 'Session.php',
'filepath' => 'libraries'
);
It's telling me that he can't redeclare class CI_Session. Alright so I guess that's how the CI-hooks work: Create a new instance of the class and then launch the method.
So I changed my approach calling a procedural function:
Code:
$hook['post_system'] = array(
'class' => '',
'function' => 'transmit_data_hook',
'filename' => 'Session.php',
'filepath' => 'hooks'
);
Code:
function transmit_data_hook()
{
$CI = &get;_instance(); // That strange semicolon seems to be a bug in the forum-software
$CI->session->transmit_data();
}
But now I've got a new problem, and I can't quite figure out why:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Gate::$session
Filename: hooks/Session.php
Line Number: 14
Fatal error: Call to a member function transmit_data() on a non-object in /[...]/application/hooks/Session.php on line 14
So I took a look inside the $CI-variable in my hook finding these class-instances available:
Code:
config
log
utf8
uri
router
output
security
input
lang
load
db
url
user_agent
encrypt
session_handling
usertracking
I'm autoloading the Session-Class running my session-routine without any problems. But why is the library already gone in post_controller-hook? Did the Codeigniter-core already automatically destroyed it at this point? I can't figure it out ): I appreciate any hints from people who know better about Codeigniters mechanisms!
Thanks for looking into my problem in advance!
Best regards
_taig