I would like to clear the session cookie when a user logs out or when their session expires. I understand that wp_clear_auth_cookie();
clears the cookie but I am struggling to understand how to implement it. I am using the following code to log a user out automatically if they are inactive for 10 minutes. (I think I found that in here too)
function myplugin_cookie_expiration( $expiration, $user_id, $remember ) {
return $remember ? $expiration : 600;
}
add_filter( 'auth_cookie_expiration', 'myplugin_cookie_expiration', 99, 3 );
Could someone kindly direct me to the right direction to achieve this result?
Try setting
$experation
to a negative integer:From the w3schools PHP page on cookies: