Make WordPress Remember A Login Forever

Watch out! This tutorial is over 7 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

To keep track of who you are, WordPress uses cookies to store important information needed for it to work. Once you are logged into your WordPress account, information is stored to that little file which lets the system know the exact time when you got there and so it can identify you later on.

For security reasons this cookie won’t let you stay logged in forever. Let’s say you logged in to your account on a public computer and forgot to log out. If WordPress wouldn’t use this security method, anyone on that computer would be able to access your WordPress admin panel. That’s the reason you might like the limited time of your session.

But if you work from home or your office and there is no need for this security option, automatic logouts might grind your gears. To stay logged in “forever”, add the following to your theme’s functions.php tell your cookie how long to stay active.

add_filter( 'auth_cookie_expiration', 'wploop_never_log_out' );
	
function wploop_never_log_out( $expirein ) {
   return 1421150815; // 40+ years shown in seconds
}

And that’s pretty much it. You may change the number of seconds in the code but it really doesn’t make any difference if it’s 20 or 40 years, does it? After you have edited functions.php, WordPress won’t automatically log you out; you will stay logged into your account forever, and ever, and ever…

…or until you delete your browser cookies, of course.