Hook to identify when user logs out

Peter Lane Posted in Component Development 2 years ago

I am looking to carry out an action when the system logs out a user for inactivity, or the logs themselves out.

Replies
gb Peter Lane Replied 2 years ago

Apologies, I have not updated the site correctly yet, I am in pain today, I'm afraid.

gb Peter Lane Replied 2 years ago

As per your suggestion, I used the following code to no avail. It did not delete the cookie. Nor did it send me an email as requested, which shows me it not get to the error log. I note that using the option '3' in the error log request did not write a log file either (if I put that at the top of the function!).

function recordlogout_init(){
        ossn_register_callback('action', 'load', 'recordlogout_cb');
}
function recordlogout_cb($callback, $type, $params){
    if($params['action'] == 'user/logout'){
        $cookie_name = "OSSNuser";
        setcookie($cookie_name, time() - 3600);
        error_log("logout",1,"[email protected]");
        return true;
    }
}
ossn_register_callback('ossn', 'init', 'recordlogout_init');
gb Peter Lane Replied 2 years ago

Thank you for quick response

Indonesian Arsalan Shah Replied 2 years ago

There is no way to find when user is logged out by system due to inactivity. If you are looking when users logs out themselves using button,

function my_component_init(){
        ossn_register_callback('action', 'load', 'my_component_cb');
}
function my_component_cb($callback, $type, $params){
        if($params['action'] == 'user/logout'){
            //do some stuff......    
        }
}
ossn_register_callback('ossn', 'init', 'my_component_init');
Premium Version

Due to the many requests in the past for additonal features and components we have decided to develope a premium version. Features like Hashtags, Videos, Polls, Events, Stories, Link Preview, etc included in it.

$199 (Life Time)
Learn More

Other Questions