Hi there,
I’ve a problem with forms on wordpress pages, this has something to do with the session handling I think.
I’ve setup my request handler in the middleware group
Route::group(['middleware' => 'web'], function () {
Route::post('/request-contact', [ContactController::class, 'submit'])->name('contact.submit');
});
My form is inside a anonymous component, that’s included on a Wordpress page template.
<form method="POST" action="{{ route('contact.submit') }}">
@csrf
</form>
The form renders, but with an empty CSRF token.
I’ve seen a similar thread with the following solution:
add_action('wp_loaded', fn () => app('session')->isStarted() || app('session')->start());
But this gives me the error:
Attempt to read property "cookies" on null
Is there some configuration that i’m missing?
Log1x
2
you might need ACORN_ENABLE_EXPERIMENTAL_WORDPRESS_REQUEST_HANDLER=true
set in .env
Unfortunately this doesn’t work.
Log1x
4
what version of Acorn are you on? assuming it’s 4.1, I can try to look into this soon.
Yes, i’m running on 4.1, thank you!
niznet
6
Are you publishing the Acorn configuration? I remember there are some providers that need to be added but I forgot which one.
I have tested it with fresh Acorn 4.1 and Sage, and it’s working as expected.
<form method="POST">
<input type="hidden" name="_token" value="ae2hD7SqWWt836tEiOTUqFoBegG1pGnqyJeqTcQa" autocomplete="off">
</form>
Here’s the repo for the test: CSRF Token Workaround
1 Like
Thanks for your response, I think I messed something up in my Radicle config. It works with a fresh install.
1 Like