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

lararocks's avatar

Auth session expires quickly

I'm using the default Laravel 5 auth controllers to authenticate users. After a user logs in, the session expires quickly in few seconds and redirects back to the auth/login page.

Any idea how to fix it?

I tries changing the expire value in config/auth.php but no luck.

0 likes
6 replies
WebKenth's avatar

Whats your environment? Homestead? Valet? custom?

Can a user actually log in? or does it immediately redirect when you click login

Snapey's avatar

check that a session file is being created in the storage/framework/sessions folder

lararocks's avatar

Thanks for helping everyone.

It was a missing break statement in my Exceptions/Handler.php file.

The code that was causing the issue:

public function render($request, Exception $e)
    {
        //return parent::render($request, $e);
        //return view('errors.custom');
        
        if ( ! config('app.debug') && ! $this->isHttpException($e)) {
            return response()->view('errors.custom');
        }
        
        
        if ($this->isHttpException($e)) {
            
            $statusCode = $e->getStatusCode();

            switch ($statusCode) {

                case '404':
                    return response()->view('errors.404');
                    break; // This was missing
            }
        }
        return parent::render($request, $e);
    }

Fixed it by adding the break statement.

Thanks all

coreysan13's avatar

For anyone else, the solution mentioned above by the author couldn't have been the real issue.

The break after the return would never be hit. Must have been something else.

Please or to participate in this conversation.