Browse Source

Extend login session to a year (auth_cookie_expiration filter)

windhamdavid 4 days ago
parent
commit
aeb71b1c7c
1 changed files with 8 additions and 0 deletions
  1. 8 0
      functions.php

+ 8 - 0
functions.php

@@ -39,6 +39,14 @@ endif;
 add_action( 'after_setup_theme', 'dw_plugs' );
 
 
+// Keep login sessions alive for a year (default is 2 days, 14 with "Remember Me").
+// There's no WP constant for this — it's the auth_cookie_expiration filter, so it
+// can't live in wp-config.php. Lower YEAR_IN_SECONDS if you want a shorter session.
+function dw_login_session( $length, $user_id, $remember ) {
+	return YEAR_IN_SECONDS;
+}
+add_filter( 'auth_cookie_expiration', 'dw_login_session', 10, 3 );
+
 function dw_editor() {
 	wp_enqueue_style( 'dw-gutenberg', get_theme_file_uri( '/css/editor.css' ), false, '1.0', 'all' );
 }