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.

After a certain amount of time WP logs out all users and forces them to log back in again. For development environments on my local machine this is obnoxious and absolutely unnecessary.

Is there an API-driven way of disabling the auto-logout indefinitely? Ideally I'd like something I can add to wp-config.php along with other dev-setup-related settings.

A plugin would be overkill for me so I won't consider it an answer, but you might as well post it as an option.

share|improve this question
    
Hey Jeremy, good to see you here on opening day! –  MikeSchinkel Aug 18 '10 at 20:57
add comment

4 Answers 4

up vote 12 down vote accepted

By default, the "Remember Me" checkbox makes you get remembered for 14 days. This is filterable though.

This code will change that value:

add_filter( 'auth_cookie_expiration', 'keep_me_logged_in_for_1_year' );

function keep_me_logged_in_for_1_year( $expirein ) {
    return 31556926; // 1 year in seconds
}
share|improve this answer
1  
This is exactly what I needed. I think a constant for this value would be really useful, but a filter is the next best thing. I could even use create_function() to do it on one line. –  jeremyclarke Aug 19 '10 at 1:40
1  
create_function() is slow and makes it hard to remove the filter. It's best practice to use a function. :) –  Viper007Bond Aug 19 '10 at 22:46
    
You can even get a recent PHP version and write it as closure: php.net/manual/en/functions.anonymous.php - WordPress suppors that. Just don't stand in the way of your own and do not use create_function() any longer. It sucks. –  hakre Aug 20 '10 at 10:15
    
Oh wait, this doesn't work in wp-config.php :( To use it I'd have to have a plugin that used this later on when add_filter() was available. –  jeremyclarke Aug 24 '10 at 15:53
    
Oh, if you want this in wp-config.php, I think you'll have to make a clone of the whole function then from pluggable.php. Rather messy. –  Viper007Bond Sep 3 '10 at 22:15
show 2 more comments

I made a plugin to solve this problem by making the cookie expiration period user-configurable.

share|improve this answer
add comment

Does this work, if you place it in wp-config.php?

function wp_validate_auth_cookie($cookie='',$scheme='') {
    return 1; // admin user id
}

Not thoroughly tested. It doesn't so much "never log me out" but rather "treat everyone as admin."

share|improve this answer
    
This is by far the most elegant solution! Amazing! –  John P Bloch Aug 18 '10 at 21:38
3  
NEVER USE IN PRODUCTION!!! Sounds like a sandbox install. –  Arlen Beiler Aug 20 '10 at 2:20
add comment

This has more to do with how you're browser stores cookies. When you login it should be saving the cookie and WordPress reads it to see if you're authenticated (at least that's what my understanind it).

On all local dev installs my username is admin and my password is admin. I don't find 8 letters to really be a big deal but maybe I type faster?

share|improve this answer
    
I use backups of the live databases, and in those I always have strong passwords on all admin accounts. I also often have different user names for different sites, and in many cases Firefox has trouble differentiating my different local installs for autocompletion purposes. –  jeremyclarke Aug 19 '10 at 1:46
add comment

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.