Limit logged in session duration (FC)
Friends, could you please tell me which tool for the duration of the session you use in FluentCommunity? My WP throws me out of the session every 48 hours. I've been logged in to your account for a long time and I'm not being kicked out of my account. What do you use for this? And if it's not a secret, what settings do you use for Nginx configuration? Thanks!
By default WordPress handles user sessions in a couple of ways:
- βNormal Login: If a user logs in without checking the "Remember me" box their session will last for 48 hours
- β"Remember me" Login: If the "Remember me" box is checked the session duration is extended to 14 days
The users experience of being logged out every 48 hours is the standard behavior.
Plugins like "Login Timeout Sessions" or "Persistent Login" allow you to configure the session duration directly from the WordPress dashboard but you can use a code snippet:
function custom_auth_cookie_expiration( $expirein ) {
return YEAR_IN_SECONDS; // 1 year in seconds
}
add_filter( 'auth_cookie_expiration', 'custom_auth_cookie_expiration' );
You can also define a constant in your wp-config.php file to control the session duration.
define( 'COOKIE_EXPIRATION', 31536000 ); // Sets expiration to 1 year in seconds
Note: be careful when changing wp-config.
Nginx itself does not control the WordPress session timeout but it can affect it in a few indirect ways (Proxy Timeouts, Caching). The session duration is controlled by WordPress's PHP and cookie settings.
Related link
