Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

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' );
share|improve this answer
1  
Looks ideal, i'll report back if not, but i'm pretty sure that's exactly what i'm after, thanks Mark. –  Mark Duncan Aug 1 '11 at 15:55
    
Doesn't actually solve the problem unfortunately(must be a result of the server being started and stopped), but for most installations this should be perfectly fine(so technically is still the correct answer). –  t31os Aug 6 '11 at 11:18
    
Interesting; I didn't realize it's the same case on my localhost; the cookie doesn't have an expire date. And this would work better in a plugin, anyway, rather than needing to be added to functions.php –  songdogtech Aug 7 '11 at 18:45

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.

share|improve this answer

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.

share|improve this answer
    
Still useful to know, thanks for the pointer.. :) –  Mark Duncan Aug 1 '11 at 15:43
    
I should of looked/googled harder/longer i guess, it's in the Best Collection thread. –  Mark Duncan Aug 1 '11 at 15:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.