How to extend user login session on WordPress

October 18, 2023 / WordPress

In this article, we will explain how to extend your user login session on WordPress.

Follow these steps to extend the user login session on WordPress.

  1. Log into WordPress.
    WordPress
  2. In the left sidebar on the Dashboard, select “Appearance,” and then choose “Theme Editor.”
    Dashboard
  3. In the Theme Editor, pick the desired Theme from the drop-down menu.
    extend user login session
  4. Now, click on the file named “functions.php”
    functions.php
  5. Enter the following code into functions.php-
    add_filter( 'auth_cookie_expiration', 'extend_login_session' );
    
    function extend_login_session( $expire ) {
    
    return 31556926; // seconds for 1 year time period
    
    }
  6. Now, save the file and exit from the editor.
  7. The login session now lasts for 1 year, surpassing the default duration set by the login session cookie.

In this way, you extend user login session on WordPress. For more information on WordPress, visit our knowledge base section.

Spread the love
Dominos Search