We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

CSRF Token Being Re-generated On Page Refresh

How Do I?

davezachry's avatar
davezachry
3 posts
10 years ago
davezachry's avatar davezachry

This morning, our install of EE (2.8.1) began displaying the “An Error Was Encountered. This form has expired. Please refresh and try again.” message on the search form and CP login.

After extensive digging and searching, we’ve traced things down to seeing that on every page load, the PHP session is being re-started and this is creating a new CSRF token / cookie. Since this is happening, any form (POST) action is giving us the above “form expired” error.

Any thoughts or causes for the PHP session to begin doing this?

The site has been working well since it’s launch about a month or so ago.

Thanks for anything help that can be provided.

       
airways's avatar
airways
154 posts
10 years ago
airways's avatar airways

I’ve seen this a few times before. Here are some ideas based on my own debugging list for login issues:

  • If you have wifi and a wired network connection, try disabling one, then the other. I have seen cases where a computer randomly switches between connections, invalidating the session immediately.

  • Add this (temporarily) to your config.php to turn off extensions, if you can login afterwards, one of your add-ons is to blame:

$config['allow_extensions'] = 'n';
  • Add this to your config.php to change to session-only logins:
$config['cp_session_type'] = 's';
  • If session-only logins still do not work, change the value like so in config.php to change to cookie-only logins then try the next few steps:
$config['cp_session_type'] = 'c';

If you still can’t login you can use this to disable the CSRF but you don’t want to leave this on.

  • Turn off form security in config.php:
$config['secure_forms'] = 'n';
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.