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

jonas91's avatar

User Session Expires

Hi i have a beta cms for a blog and i want my users to not expire their session and to logout from my cms only when logout(like laracast).

I use the default auth laravel here is my session controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;


class SessionController extends Controller {
   
    public function __construct() 
    {
      $this->middleware('guest', ['except' => 'destroy']);
    }

    public function create() 
    {
        return view('sessions.create');
    }

    public function store() 
    {
        if (! auth()->attempt(request(['email', 'password']))) {
            return back()->withErrors([
                'message' => 'Wrong'
            ]);
        }

        return redirect('/'); 
    }

    public function destroy() 
    {
        auth()->logout();
        return redirect('/login');
    }

}

0 likes
2 replies
jonas91's avatar

@Jeroen i use this in my seesion.php

    'lifetime' => 5 * (60 * 24 * 365),

    'expire_on_close' => true,

so my seesion ends after 5 years correct?

Please or to participate in this conversation.