Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
298 views
in Technique[技术] by (71.8m points)

Laravel 8 Timeout A Manually Created Session

I'm busy implementing sessions into a Laravel 8 app (not using the Breeze template) and I don't quite understand how the timeout works

I have a controller to create a very simple session on login

class LoginController extends Controller {

    public function authenticate(Request $request) {

        // create the most basic session I can
        $request->session()->put('exists', 'Y');

        return redirect()->route('welcome');

    }

}

And the middleware to test it

class SessionCheck {

    public function handle(Request $request, Closure $next) {

        if (! session()->has('exists')) {
            return redirect('login');
        } else {
            return $next($request);
        }

    }

}

I see that there's a variable in the .env for SESSION_LIFETIME=60 but what does it do? It doesn't seem to be emptying out the session vars, how can the timeout be checked?

question from:https://stackoverflow.com/questions/65651857/laravel-8-timeout-a-manually-created-session

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...