PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
This works as expected on my website however, instead of redirecting to start.php on my localhost, it refreshes the page that it's called from.
This used to work on my localhost because that's where I tested it, but for some reason it no longer redirects. Any suggestions would be greatly appreciated.
I'm looking at the system log and see nothing remarkable. My localhost setup is MAMP and I've cleared my cache files in the browser settings. Here is the only system log entry at the time of the refresh:
WebProcess[519]: Periodic CFURLCache Insert stats (iters: 363) - Tx time:0.434139, # of Inserts: 4, # of bytes written: 81477, Did shrink: NO, Size of cache-file: 4786176, Num of Failures: 0
First comparison should be $session_life < $redirect_inactive. As you have now, 0-600 will do nothing, 600-615 will redirect,and >615 will reset the timer.
Depending on when you're hitting the pages, that could be the problem.
I really appreciate you analyzing my code however, after reading and trying your suggestion, I realized the code is okay and performing as intended because I want nothing to occur if 0-600, I want the the re-direct if 600-615,and if >615 I want the timer to be reset. The timer reset over 615 allows for user lag.
My issue seems to be a difference in server settings on my localhost and my hosted web server. This code works as expected on my hosted server but only refreshes the current page on my localhost instead of re-directing to start.php on my localhost.
I have tried changing the $inactive variable on my localhost but this has no apparent affect. If I change any text on the page, it's recognized immediately.
I'm not sure how to proceed with this. Any suggestion is greatly appreciated.
By the way, everything refreshes on my localhost EXCEPT the header re-direct header("Location: start.php"); I don't know if that helps but I've tried "include" as well.
Moving my comments from the first entry to below the code resolved this issue on my localhost and the code works on my hosted server as well. I can only guess this has something to do with the header() function on my localhost. I wanted to circle back and make sure folks has a resolution.
If moving code around fixes it then it sounds like you were outputting something (unintentionally) before the header(). But that would have shown up in the error log... if you had the right settings, so maybe that's it.
As for the timing, so there's a 15 second window during which one can get logged out for inactivity, and that's it? If you miss that window then you don't get logged out... If that's really what you want, alright, I'm just saying that seems really odd.