How To Extend the Auto Logout Period

Snippets by IsItWP

Are you looking for a way to extend the auto logout period? This snippet will extend the time the authentication cookie will expire to one week.


Add this code to your theme’s functions.php file or in a site-specific plugin. Note the returned value is defined in seconds.

function logged_in( $expirein ) {
   return 604800; // 1 week in seconds
add_filter( 'auth_cookie_expiration', 'logged_in' );

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 6 Best WordPress Security Plugins Compared.

Comments  Leave a Reply

  1. Nice snippet, but is it possible to force logout user if accessing a specific page?

  2. Tweets that mention Wordpress Extend auto logout period – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com December 24, 2010 at 8:23 pm

    […] This post was mentioned on Twitter by wp_freak. wp_freak said: #wordpress Extend auto logout period http://bit.ly/g8NxjE […]

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!