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.

link|improve this question

feedback

2 Answers

up vote 4 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' );
link|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
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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