Lego2012
12/13/2016 - 9:46 AM

Admin and Dashboard - Keep logged in WordPress for a longer period

Admin and Dashboard - Keep logged in WordPress for a longer period

<?php
// Do NOT include the opening php tag

<!--
When you work on public wi-fi networks, or not on your computer, it's always good practice to log out from those devices. But when you're on your home network and your computer, getting kicked out after a while might be annoying to some. How about extending the time of your WordPress login session? This code will do the trick, just open the functions.php file and copy it: 
  -->

add_filter( 'auth_cookie_expiration', 'stay_logged_in_for_1_year' );
function stay_logged_in_for_1_year( $expire ) {
  return 31556926; // 1 year in seconds
}

<!-- 
By the default, WordPress will keep you logged in for 2 weeks when you check the "Remember Me" option at login. You can set the expiry date of the authorization login cookie by replacing the "31556926" with your preferred time span. 
-->