Skip to Content Skip to Menu

Intermittent UE_SESSION_EXPIRED / invalid CSRF token during login on Joomla 6

1 hour 45 minutes ago #344566 by kletterdorf
we are experiencing intermittent login failures with Community Builder on Joomla 6. I have been able to reproduce the issue reliably and traced it down to CB's form-token validation.Reproducible scenario
  1. User A is logged in.
  2. User A logs out.
  3. The login form is used to log in as User B.
  4. Instead of logging in, Community Builder displays:

Session expired or cookies are not enabled in your browser. Please press "reload page" in your browser, and enable cookies in your browser.

The German translation is
Code:
UE_SESSION_EXPIRED
.The issue has been observed with Firefox on Windows. We also have a user for whom the problem occurs intermittently on two Windows computers, while login from Firefox on Android works.Clearing the site's cookies/session data temporarily appears to resolve the issue.What I foundThe failing request is:
Code:
POST /einloggen → HTTP 200
A successful login produces:
Code:
POST /einloggen → HTTP 303
I traced the failing request to
Code:
components/com_comprofiler/comprofiler.php
, function
Code:
login()
.Before username/password authentication takes place, CB performs:
Code:
if ( ! Application::Session()->checkFormToken() ) { return; }
This calls
Code:
CBLib\Session\Session::checkFormToken()
:
Code:
if ( Application::Cms()->checkFormToken( $method ) ) { return true; } $error = CBTxt::Th( 'UE_SESSION_EXPIRED', 'The most recent request was denied because it had an invalid security token. Please go back or refresh the page and try again.' );
For Joomla 6, CB ultimately delegates this to:
Code:
return Session::checkToken( $method );
So the failure occurs during CSRF token validation, before CB evaluates the supplied username or password.The token is present in the POSTI inspected the failed POST request in Firefox Developer Tools. The form does contain the Joomla/CB token, for example:
Code:
7aad6c5e3ff32f7154b9c11281481279: "1"
along with the normal CB login fields (
Code:
option=com_comprofiler
,
Code:
view=login
,
Code:
op2=login
,
Code:
loginfrom=loginform
, username, password, etc.).CB generates this field using:
Code:
Application::Session()->getFormTokenInput()
with the token name supplied by Joomla and value
Code:
1
.Therefore this does not appear to be a case where the browser simply omits the CSRF token.
Code:
Session::checkToken('post')
rejects a token that is present in the submitted form.Additional observationIn another occurrence we saw the following sequence:
Code:
POST /einloggen → 303 GET /home → client cancelled request POST /einloggen → 200
The first POST had actually authenticated the user successfully. Nevertheless, the subsequent POST resulted in the
Code:
UE_SESSION_EXPIRED
message. The user could see the error message while already being logged in ("Logout" was displayed in the site navigation).QuestionsCould this be a known issue with Community Builder's session/CSRF handling on Joomla 6, particularly after logout/session regeneration?Is there anything specific we should check regarding CB login forms and Joomla session regeneration after logout?I can reproduce the "User A logout → User B login → invalid token" case and can add temporary diagnostic logging if you need the expected token, submitted token and Joomla session ID for the GET/POST sequence.One additional minor issue: the current German
Code:
UE_SESSION_EXPIRED
translation still says that the session has expired or cookies are disabled, while the current English default string correctly describes the actual condition as an invalid security token. This made the issue initially look like a browser-cookie problem.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 50716
  • Thanks: 8692
  • Karma: 1475
1 hour 2 minutes ago - 1 hour 1 minute ago #344567 by krileon
CB isn't responsible for form token validation. We simply call Joomla's API, add it to the form as a hidden input, then validate it on POST using Joomla's API. It routes through our middleware API to allow compatibility with multiple Joomla versions, but those immediately just call Joomla API.

You most likely have a caching issue of some kind. Are you using Joomla page caching or a 3rd party caching extension? Session regeneration should happen automatically by Joomla after the logout redirect. CB itself also calls Joomla's checkSession function to force a regeneration if you logged out through CB as a workaround for possible session regeneration issues. Not much more we can do there as CB doesn't manage the Joomla session.

translation still says that the session has expired or cookies are disabled, while the current English default string correctly describes the actual condition as an invalid security token. This made the issue initially look like a browser-cookie problem.

Translations are entirely a community driven effort. Sounds like that language string was never updated. You can fix it using language overrides shown below.

www.joomlapolis.com/blog/kyle/18701-language-overrides-have-arrived


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 1 hour 1 minute ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum