The question:
I want to logout user autometically when user is idle for more than 10 minutes.That mean suppose user is logged in to a site and user didn’t browse any pages for more than 10 mins.when he browse any page after 10mins, it will logout user and redirect to login page.Any Solution?
Advance Thanks.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
You just need to add your filter hook like this:
function myplugin_cookie_expiration( $expiration, $user_id, $remember ) {
return $remember ? $expiration : 600;
}
add_filter( 'auth_cookie_expiration', 'myplugin_cookie_expiration', 99, 3 );
You can add it to your theme’s functions.php file.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0