'Your session has expired' when submitting a form in Statamic
How to solve the redirect to login issue in Statamic after submitting a form on the front end
Just a real quick one. While testing a Statamic site on our staging servers, I came across an issue where on submitting a contact form, the user would be presented with the Statamic login page and an error notice saying "Your session has expired."
After doing a bit of digging, I discovered – thanks to an answer to a post on the Statamic forms by Erin Dalzell – that static caching was the root cause of the issue.
We'd turned on Static Caching to boost performance, but it meant that the session wasn't being refreshed when someone tried to submit a form. By logging in to the site and adding the slug to the excluded pages (in this case, /contact
), we were able to solve the problem.
Hopefully this will help out someone else facing the same issue.