Using sessions_end hook
Should be pretty simple, right?
if ($this->EE->session->userdata[‘member_id’] == 0) { //user is not logged in }
I’ve also tried group_id
But when I test that by visiting the site while not logged in, I get:
A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$userdata Filename: gcx/ext.gcx.php Line Number: 160
A PHP Error was encountered Severity: Notice Message: Undefined property: stdClass::$flashdata Filename: libraries/Functions.php Line Number: 368
160 being the line where I am testing for the member_id/group_id
Any ideas?
Here is the entire function: http://pastie.org/private/wwdgsadqyqbgg3gyf3bvzw
I think the session object isn’t yet attached to this->EE at that point. But conveniently, you are passed the session object itself as a parameter to sessions_end:
function my_extension_hook_into_sessions_end(&$session)
{
if ( ! $session->userdata('member_id')) {
//not logged in
}
}Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.