How to solve Page Expired Due to Inactivity in Laravel - laravel

I am a PHP developer using Laravel framework and currently i have an application which is in production. The users are being forced to log in every time even if they just logged in in less than 2 mins and get the message The Page expired due to inactivity. This is causing me headache as the application is doing just fine in the development environment in my my local machine.
I have search for solutions but non is working for me including generating keys using php artisan command, clear cache,config,route and view, i have also tried to increase the number of minuted for the session to expire to up to 8 hours but the same issue still occurring.
I am actually stranded and don't know what to do else,please i need a help to get out of this.
Thanks in advance

Option 1:
Set session lifetime in .env file to SESSION_LIFETIME=120 (2 hours)
Option 2:
Try all of them.
composer dump-autoload
php artisan optimize
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
Option 3: if these have no effect add remember me checkbox on login form who save session token for long time

Related

Laravel 5 slow refresh waiting for blocked storage access requests from trackers

I've moved a laravel app form a domain to another. All works well but I noticed, after clicked on subitting a button, that it spend 20seconds to refresh the paige. During this the system is waiting for an external components (addthis.com, google ads etc..), end when solved the process in console I read the "Blocked: Storage access requests from trackers" message.
I've setup session.php to 'same_site' => 'lax' (it was null..) but nothing happends.
Do you have some idea?
How to include safe url list as walk-artoud it ?
Thanks
Hi after this change you should clear the cache of config laravel
on your console you write :
php artisan config:clear
to permit accept the changes and then clear the cache of your application with
php artisan cache:clear
and see if this works.
I was tried with php artisan optimize:clear with no results, but as you suggest it works right, thank you a lot!
Have I repeat this periodically or only if I update session.php?

How to make my Laravel API project with Passport faster?

I'm developing a Laravel API based on larapi project and I think I'm doing something wrong, because every request to my API takes about 3 seconds to return, don't matter the size of the response.
I've searched a lot and already tried to run the following commands, but my requests still slow:
composer dump-autoload -o
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
My server and database server are hosted separatedly. I already did some tests with other projects and the servers runs fast. It seems to be a problem with Passport (Laravel OAuth authentication), it try to authenticate the user's access token on every request.
Has anyone faced this problem?
Thanks for your attenion.
Regards.

How to cache specific routes or remove from cache specific routes in Laravel?

The fact is that I am connecting to sockets from another domain and have been trying for a long time to find out why I get 419 error when connecting to a private channel. It turns out that the csrf token is cached and I can successfully connect when the routes are not cached.
I don't know of a way to be selective about it but try running:
php artisan route:cache
php artisan cache:clear
Or for the whole set of cache clears you can run php artisan optimize
The other option would be to wait out the cache expiry but I doubt you would want to do that!

Laravel Website on local server is showing error (The page has expired due to inactivity. Please refresh and try again. )

My Website is working fine on hosting server, but when I downloaded all files and want to make changes on local server is showing error on submitting the form. All form has CSRF Token
The page has expired due to inactivity. Please refresh and try again.
I have cleared cache, route, and even generate a new key by the following command.
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
php artisan generate:key
Run composer update
If still not work navigate to bootstrap - > caches and delete files present in it.
To test if token is passing use network tab in inspect element of browser.

Laravel 5.2 fails to read the session cookie

I have a issue in my laravel applications, i'm using XAMPP test run my applications locally on windows machine.
My problem is that Laravel applications get's logout suddendly, this happens very often, if i refresh the same page like 4 , 5 times it get's logged off. but when i check the chrome dev tools Cookies, Laravel_session is still there.
Any idea as to why this could happen?, also, i don't get the same issue when it's hosted online.
May be the problem is with session driver. Because as you said that if i refresh the same page like 4 , 5 times it get's logged off, by default session storage is file and you 4-5 time request may messing it up. Here I'm not sure but this stuff may solve your issue.
Change SESSION_DRIVER=file to SESSION_DRIVER=database in .env
Create session migration with php artisan session:table artisan
code
Run composer dump-autoload to regenerates the list of all
classes
Run php artisan migrate to migrate.
NOTE: You can run single migration file by separate with subfolder

Resources