Skip to main content

Logging out

Using fluent community with fluent auth, so not sure which is effecting this, but users get logged out to much and we want to extend the cookie or whatever is causing the constant log outs, can I fix this?

Shahjahan Jewel

Do you have any security plugin that is reducing the session time?

Doug Dennison

Shahjahan JewelΒ not too sure, the only plugins that could be affecting anything like this are:

  • FluentAuth
  • Smush
  • Autoptimize
  • StackCache

Plus, we're using every fluent plugin available i think! 😍

Shahjahan Jewel

Doug DennisonΒ WordPress auth cookies expire in 2 days by default, or 14 days if "Remember me" is checked. You can extend that by this php snippet:

add_filter( 'auth_cookie_expiration', function ( $length, $user_id, $remember ) {
    return 90 * DAY_IN_SECONDS; // 3 months for everyone
}, 10, 3 );

I will check if I can add an option in FluentAuth. For now, you can use the snippet.

Doug Dennison

Shahjahan JewelΒ thanks. Add this to the functions php file?

Shahjahan Jewel

Doug DennisonΒ Yes, Or you can use FluentSnippets. https://fluentsnippets.com/

Doug Dennison

So you have context - this is more of an issue with the mobile app you launched. As mobile apps via appstores dont really log you out, but the saved app you suggest logs the user out the same as via browser, which isnt great for users.

Doug Dennison

Shahjahan JewelΒ already use FluentSnippets haha, thanks!

Doug Dennison

Thing is, with magic link there is no 'remember me' option, so logs everyone out every 2 days!

Shahjahan Jewel

Doug DennisonΒ the code snippet will handle all auth cookie so that will work universally.

Doug Dennison

Shahjahan JewelΒ so I got logged out, (which may have happened before I applied the changes, see attached for my fluentauth setup), but... when I get logged out in the new PWA app, then use magic link to log back in, it logs you in via the browser but not in the app. On iPhone scrolling down to refresh isn't working on this, so I remain logged out. Am i doing something wrong, or is the function not added correctly?

Doug Dennison

Shahjahan JewelΒ the code snippet didnt work, I just got logged out. Claude recommended this instead, is this ok?

add_filter( 'auth_cookie_expiration', function ( $length, $user_id, $remember ) {
return 90 * DAY_IN_SECONDS;
}, 9999, 3 );

V annoying especially with the new app feature that I keep getting logged out and it wont allow me to log back into the app, so its kinda useless!

Shahjahan Jewel

Doug DennisonΒ yes that's correct.