Hey guys,
From my tests $SESS->cache doesn’t seem to be persistent between the sessions_start hook and when I try and use it in a plugin on the same page load.
Can one of the EE team or one of the independent developers confirm / explain this?
I thought the $SESS was persistent until the page was finished loading
Cheers
After taking a look at the hook (which I should have done before posting my first message), I wonder if you’re forgetting to use a reference. Does your function look something like A or B?
A: function my_session_start_function(&$OBJ)
B: function my_session_start_function($OBJ)
Hey guys,
I have attached a simple example that demonstrates the issue.
Use {exp:lg_pi_test:render} to output the PI $SESS data.
From what I can tell it looks like the plugins create a new $SESS variable???? maybe.
It would be great if one of you guys could take a look at this for me 😊
Ah, that hook is inside the Session class constructor so until it finishes running the constructor, PHP will not have assigned anything to the $SESS global variable yet. So accepting by reference will be needed (at least for PHP 4 compatibility - 5 will pass objects by reference by default if memory serves):
function sessions_start(&$obj)
{
$obj->cache['lg'] = 'test';
}
Ah, that hook is inside the Session class constructor so until it finishes running the constructor, PHP will not have assigned anything to the $SESS global variable yet. So accepting by reference will be needed (at least for PHP 4 compatibility - 5 will pass objects by reference by default if memory serves):function sessions_start(&$obj) { $obj->cache['lg'] = 'test'; }
Thanks Derek…
much nicer than my
// check if the session exists if not start one
if(session_id() == "") session_start();
// create an empty array for the language files
$_SESSION['lg_ml']['languages'] = array();
Work around
After taking a look at the hook (which I should have done before posting my first message), I wonder if you’re forgetting to use a reference. Does your function look something like A or B?A: function my_session_start_function(&$OBJ) B: function my_session_start_function($OBJ)
I guess you where right as well… 😊
Thanks for bot of your help…
The documentation for the addon can be found here. The addon should be available soon.
Cheers again. If I was at SXSW I would buy you both a beer
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.