Reputation: 9838
I'd implemented a simple time-out mechanism for my website which stores instant of last user activity in the $_SESSION
array.
It checks when a request is sent to the server. If its more than 20 mins since the last request, I log out the user and the user is sent to the login page.
But I get this "redirect loop" message which shows up on Chrome. Is there a common mistake that I am making?
(Do I need to tinker with server-side settings?)
Thanks.
Upvotes: 0
Views: 2377
Reputation: 437434
The redirect loop happens obviously because the login page is itself redirecting the user to the login page, ad infinitum. Why this happens is not clear because you don't show any code, but if you correct this the problem will go away.
For example, if the "last request" value for a user with a freshly created session (i.e. one whom you have just logged out before redirecting) is a zero timestamp (1/1/1970) then this would qualify as more than 20 minutes earlier, which could trigger another logout/redirect, etc.
Upvotes: 1