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

shadrix's avatar
Level 12

Cannot log in - Session not working in artisan serve but in valet it does

Hey, I don't know why but my session is not working while using php artisan serve --host 0.0.0.0

First I had to remove \App\Http\Middleware\VerifyCsrfToken::class,, but now while debugging on my phone I want to log in and it won't work.

I think my SESSION_DOMAIN is wrong, but I cannot figure it out.

With Laravel Valet my .env looks like this: (everything works fine with it)

APP_URL=http://myproject.test
SESSION_DOMAIN=.myproject.test #using it for subdomains

Now with php artisan serve it's

APP_URL=http://192.168.1.34:8000
SESSION_DOMAIN=192.168.1.34

But I had to remove VerifyCsrfToken because for some reason I get TokenMismatchException.

I don't want to use Laravel Valet Serve because it is so slow...

Any idea why my session is not working?

0 likes
5 replies
realrandyallen's avatar

What happens if you remove SESSION_DOMAIN from your .env entirely? Also run

php artisan cache:clear

Just incase

Snapey's avatar

you dont need to do anything with SESSION_DOMAIN

Thinking that `php artisan serve' is quicker than valet is a joke. PHPs built in server only supports one connection, and it should be no faster... if anything, slower

shadrix's avatar
Level 12

@SNAPEY - @snapey you are right but as written above I'm using it to view it on my phone. Since Valet Share goes through ngrok.io it's way slower, because of the "middleman". If I use artisan serveand go through the local network it's super fast.

shadrix's avatar
Level 12

Maybe for feature readers, I could not fix it, but I made valet share much faster.

First of all I created a free account on ngrok and then with ~/.composer/vendor/laravel/valet/bin/ngrok authtoken <YOUR_AUTHTOKEN>

You can add your auth token.

So after that you need to specificy your region. Since I'm from Europe it made it super fast.

just write: valet share -region=eu

Please or to participate in this conversation.