Support the ongoing development of Laravel.io →
posted 10 years ago
Session

Hi everybody

I want to logout my user after one hour.I use session for that .

I set lifetime='60'

but it doesn't work , by the way I don't want to use it. is there any other way?

when user login :

 $now=new DateTime();
    Session::put('time',$now);

so how can I check the time is next 1 hour? I used the lifetime set it to 60. but didn't destroyed after that .I checked with this code:

if(Session::has('time'))
    {     echo 'something';  }

is there other way? or what's my wrong? thanks everybody

Last updated 2 years ago.
0

Well, if I understand correctly, you're going to need to compare times. So when a user logs in, set a session with the time they logged in. And then inside of a Route filter or somewhere, you can check to see if that time exceeds an hour.

Read over the first answer to this stackoverflow question

Good luck.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

prgmsaha prgmsaha Joined 20 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.