Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JustInCase's avatar

Laravel session not working

Hello everyone , I have hosted laravel application on vps ( Plesk ) and i seen that csrf on forms stopped working and then sessions were not working , no session is being saved , is there anything i should configure? i tried every possible thing

0 likes
12 replies
tykus's avatar

Might help if you shared what you are using for Sessions (file,database,redis???). And what you have tried because - i tried every possible thing is meaningless.

JustInCase's avatar

@tykus i tried , php artisan key:generate , changing permissions , changing settings etc Nothing worked

tykus's avatar

@mrphp are you using the web routes (or web middleware group) so that the Session is (should be) started?

Snapey's avatar

You have introduced some content before the opening <?php in one of your files.

What have you changed lately? Version control?

JustInCase's avatar

@Snapey Its working on shared cpanel hosting , but its not working in vps , is there any configuration i have to do in vps?

JustInCase's avatar

@Snapey

array:4 [▼ "_token" => "6lBdi0rrSBx2duK4vjy70cwb45QfZoDX7j29PMJ1" "username" => "admin" "password" => "admin" ]

and i am getting csrf mismatch error even though token is present

Ayzerobug's avatar

I'm also experiencing the same issue. When site was working well on Shared Hosting but when i moved to a VPS server. I'm fackinf this issue

Ayzerobug's avatar

There was an empty line at the beginning of my index.php file in the public folder. Remove the empty line fixed the issue

Please or to participate in this conversation.