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

pkundariya's avatar

NGINX server with Laravel has auth redirection problem

Hello Guys,

I had a problem with NGINX hosting with laravel authentication problem.

In my application laravel redirecting continuously to same page and it become loop now.

i have three page

Page 1. dashboard Page 2. login Page 3. users

When i try to access users page without authentication it redirects me to login page which is correct.

When i access users after login it redirect me to dashboard which is not correct. The reason is i have coded in login page header if user is logged in than he will redirect to dashboard instead of loading login screen.

So in this case this problem happens.

This problem only happens in rear case when session timeout or direct url entered by user.

I have tried to override header method with no cache but it will not work because of server is NGINX so basically header method will not work.

Is there anyone expert who can help me out for this problem?

Thanks Parth

0 likes
4 replies
nnnayeem's avatar

You are having this issue because laravel is not properly storing session data. Double-check in .env:

APP_URL=http://virtaul_domain
SESSION_DOMAIN=.virtual_domain

Here virtual_domain must not be localhost.

Snapey's avatar

@nnnayeem don't mess with session domain unless you know you need it

it's usually good to leave it as it is

Snapey's avatar

we need to see code to see what you changed

Please or to participate in this conversation.