How can i increase the login expiration length?

As the title says, how can i increase the login expiration period?

Running a local install it’s a little annoying to have to keep logging in, despite the fact i have the browser remember login credentials it’s an extra step i have to perform everytime i fire up the local server.

I assume if i increase the cookie expiration period i’ll avoid the need to keep logging in(as often).

Have googled and searched the forums, but all i found were unresponded to threads and i’m not in the mood for digging through code to work it out.

I don’t need an in-depth answer, just some pointers on suitable hooks(if any exist for this purpose), i can work out the rest from there.

Off to find somewhere cool to sit now, upstairs is roasting hot right now(hot weather here) i think the laptop might just die if i keep it on any longer, i’ll be keeping tabs on the question from another system in a cooler area of the house though and looking forward to any pointers you guys have for me.

Solutions Collecting From Web of "How can i increase the login expiration length?"

Don’t know if this is the best way, but I’ve been using this in functions.php in my themes:

function keep_me_logged_in_for_1_year( $expirein ) {
   return 31556926; // 1 year in seconds
add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );

this doesn’t answer your question specifically, but you can pass your user id to wp_set_auth_cookie() and it will log you in.

edit – and it appears it’s pluggable and has a remember parameter that expires the cookie in 14 rather than 2 days.

I know this has been answered and accepted a long time ago but taking into account the comments:

Doesn’t actually solve the problem unfortunately…

…And this would work better in a plugin, anyway, rather than needing to be added to functions.php

I thought I would give you a late answer as well. So.

There is a plugin that does exactly what you asked for. “Always Remember Me”

From the description:

The ‘Remember Me’ checkbox on the login form will be always checked, and instead of logging you in for 14 days, the expiration is set to one year.

As far as local development goes (and this is real cool), by the same author there is the “No Login” plugin.

Skip the login form: every visitor automatically auths as an admin. FOR ‘LOCALHOST’ TEST SITES only, obviously, like when designing a plugin or a theme and testing it across various browsers.