Viewed   87 times

My register page is showing the form properly with CsrfToken ({{ csrf_field() }}) present in the form).


<form class="form-horizontal registration-form" novalidate method="POST" action="{{ route('register') }}">
        {{ csrf_field() }}

I am using inbuilt authentication for the users. Have not changed anything except the routes and redirects.

When I submit the form (just after reloading also), it gives that The page has expired due to inactivity. Please refresh and try again. error.

My be I am missing a very small thing. But not sure what it is. Any help?


Found the issue. The session driver was set to array. Changed it to file and the error is gone now. But what is wrong if I use array?



If you're coming to this answer directly from a search, make sure you have already added the csrf token to your form with {{ csrf_field() }} like the OP.

If you have your session driver set to file:

May have something to do with the storage_path not being writable. This is where it stores session data regarding tokens if you're using file based sessions. The can be verified with is_writable(config('session.files'))

For the OP, the session driver was set to array. Array is for testing only. Since data is not persisted, it will not be able to compare the token on the next request.

The array driver is used during testing and prevents the data stored in the session from being persisted.

Check config/session.php

Lastly, an issue I just had, we had a project which has the session domain and secure settings in config/session.php but the development site was not using HTTPS (SSL/TLS). This caused this generic error since was set to true by default.

Friday, September 23, 2022

I had the same problem on localhost:8000 (php artisan serve). Maybe it's coincidence, but try on "clean browser" , other than you used with previous development. For me it worked.

It seems that the problem is with cookies from development with previous Laravel versions, on the same url.

Monday, December 5, 2022

You can override the default view by placing a 419.blade.php file in the resources/views/errors folder.

If you're using an editor with global search capabilities, you can search for the error message inside your project. For example, in Visual Studio Code you can press Ctrl + Shift + F to search inside the project.

I use it all the time to find the files which are part of the framework that I need to customize.

More on overriding the error views in this section of the official docs.

Friday, October 21, 2022

To constraint eager loading relations you can pass a closure to the eager loading query, and to query a relation you can use whereHas function, so it would look something like this:

Post::with(['product.categories.attributes' => function($query) {
    // Eager load constraint
    $query->whereHas('post_attribute', function ($query) {
        $query->where('product_id', 1); // Filter by the joined data

Hope this helps you.

Wednesday, December 7, 2022

For merging whereDate and between you can use something like this:

User::whereBetween(DB::raw('DATE(created_at)'), array($from_date, $to_date))->get();

sql :

select * from `users` where DATE(created_at) between '2018-02-01' and '2018-02-06'
Saturday, September 17, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :