johnnyblaze9 Posted May 13, 2008 Share Posted May 13, 2008 How do I create a timeout code? Is it a default amount of time or can it be changed? Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/ Share on other sites More sharing options...
947740 Posted May 13, 2008 Share Posted May 13, 2008 You could be a little bit more specific? What are you talking about? Something that will refresh the page at (e.g.) 10 seconds? Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539854 Share on other sites More sharing options...
revraz Posted May 13, 2008 Share Posted May 13, 2008 sessions, cookies... so many things it could be. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539859 Share on other sites More sharing options...
johnnyblaze9 Posted May 13, 2008 Author Share Posted May 13, 2008 I just need to make sure if someone leaves the page open it will log itself off....is there a way to log people out if they close the page too? Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539864 Share on other sites More sharing options...
947740 Posted May 13, 2008 Share Posted May 13, 2008 You could use a javascript onunload="function()" in the <body> tag to call a php script that would log them off. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539865 Share on other sites More sharing options...
revraz Posted May 13, 2008 Share Posted May 13, 2008 Don't know, what does "log out" mean for your scripts? What are you using to keep them logged in. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539868 Share on other sites More sharing options...
soycharliente Posted May 13, 2008 Share Posted May 13, 2008 Sessions are probably your best bet. By using a cookie to store the login session, you can also set how long it's good for. So if they try to come back and the time limit has expired, they will not be logged in. I have never done it before, so I can't offer any concrete verbiage as to what exactly goes on. The same can be true for if someone leaves the page open. If the cookie is only good for so long, whenever they try to move to another page, then they won't have access to it because they will no longer be logged in. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539869 Share on other sites More sharing options...
947740 Posted May 13, 2008 Share Posted May 13, 2008 To expound on charlieholder's thoughts, my scripts use a $_SESSION variable, so as long as they keep the browser open, they will be logged in. When the browser closes the session is over, so they are logged out. If you want them to be logged in for as long as they want, you need to use an infinite cookie, or something like that. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539873 Share on other sites More sharing options...
revraz Posted May 13, 2008 Share Posted May 13, 2008 The garbage collector on the server side has a probablity setting, and if it triggers, it checks the session's last activity and compares it to the timeout setting. If it has expired, it deletes the session. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539874 Share on other sites More sharing options...
revraz Posted May 13, 2008 Share Posted May 13, 2008 There is no such thing as a "infinite cookie". They all have some type of expiration date or can be manually deleted. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539878 Share on other sites More sharing options...
947740 Posted May 13, 2008 Share Posted May 13, 2008 I understand that; you could make a cookie that lasts as long as possible and just recreate it every time the user goes to the website. This way, it would appear to be infinite. Quote Link to comment https://forums.phpfreaks.com/topic/105419-timeout/#findComment-539879 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.