pengu Posted May 14, 2010 Share Posted May 14, 2010 I have a few questions. First one is about phpBB forums, as an example. You log in, do your thing and exit the browser, now it will still say you're logged in for a period of 5-10 minutes or so, even though you have exited via the browser. After that time period it will then say you're not still logged in, while checking the users. How is this achieved? Because I thought a field in the phpBB_Users would be updated and from my understanding the only way to change that is to trigger it, via a logout button. My second question, I'd like to use MyBrute as an example, thinking of it in a database sort of view. You get to do 3 fights a day, the next day this 3 fights thing is reset. Can this be achieved automatically, say, through a script or would someone have to manually run a query every day? Cheers, Pengu. Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/ Share on other sites More sharing options...
Deoctor Posted May 14, 2010 Share Posted May 14, 2010 hai for your first thing this can be achieved by some thing like this using the mysql tables. when a user logs in a column will b updated with a value that the user is logged in let us consider the value to be updated as 1. so who all users have the value 1 in that column they are meant to be as logged in users.. when the user click on loggout the value will be changed to 0. this means that the users with value zero wil be considered as logged out users. regarding the second one. this can be achieved by running an auto script like that of a cron which will automatically update the users to the three fights everyday at a particular time.. Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1058104 Share on other sites More sharing options...
ignace Posted May 14, 2010 Share Posted May 14, 2010 who all users have the value 1 in that column they are meant to be as logged in users.. when the user click on loggout the value will be changed to 0. this means that the users with value zero wil be considered as logged out users. Wut!? I NEVER use the logout button meaning that your website will show me as logged in ad infinitum if your code is screwed it may also mean I will not be able to login anymore ad infinitum. And why make it so difficult if it's so easy?? How is this achieved? Because I thought a field in the phpBB_Users would be updated and from my understanding the only way to change that is to trigger it, via a logout button. session_set_cookie_params(3600);//remain logged in for one hour session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1058138 Share on other sites More sharing options...
Deoctor Posted May 14, 2010 Share Posted May 14, 2010 hai ignace what i meant was that i am making the column change values with the code to zero or one depending on the status of the user. i dont think that will screw up anything.. Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1058154 Share on other sites More sharing options...
ignace Posted May 14, 2010 Share Posted May 14, 2010 i dont think that will screw up anything.. It will if the OP queries SELECT .. FROM users WHERE username = $username AND password = $password AND logged_in = 0 Which will return no results as he is still logged in. AND logged_in = 0 Is not so uncommon if you want to disallow re-login. Anyway there are better and more efficient ways to do this: 1) session_set_cookie_params(3600);//remain logged in for one hour session_start(); 2) A sessions table sessions (id, user_id, date_last_modified, lifetime) Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1058194 Share on other sites More sharing options...
pengu Posted May 18, 2010 Author Share Posted May 18, 2010 Hi Ignace thanks for that... BUT cookies wont show 'WHO IS ONLINE' sort of thing will it? Because it doesn't update the table. Right? I will Google cron, this is server side I'm assuming. Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1059866 Share on other sites More sharing options...
DavidAM Posted May 18, 2010 Share Posted May 18, 2010 I would think the easiest way to do this would be to have a column in the user table called, oh, I don't know, "LastAccess". Every time the user accesses any page, update this column to NOW(). When you want to know how many users are logged in, select a count of users where LastAcccess is greater than NOW() - 5 minutes (or whatever time frame you want). As for the 3-a-day thing. That needs 2 columns in the user table, LastFightDay, and DayFightCount. If LastFightDay is today and DayFightCount is less than 3, then let them fight and increment the count. If LastFightDay is before today, set the count to zero, change the Day to today, let them fight and increment the count. Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1059885 Share on other sites More sharing options...
pengu Posted May 18, 2010 Author Share Posted May 18, 2010 I would think the easiest way to do this would be to have a column in the user table called, oh, I don't know, "LastAccess". Every time the user accesses any page, update this column to NOW(). When you want to know how many users are logged in, select a count of users where LastAcccess is greater than NOW() - 5 minutes (or whatever time frame you want). As for the 3-a-day thing. That needs 2 columns in the user table, LastFightDay, and DayFightCount. If LastFightDay is today and DayFightCount is less than 3, then let them fight and increment the count. If LastFightDay is before today, set the count to zero, change the Day to today, let them fight and increment the count. Thanks, first part is helpful. I believe a cron job thru cpanel will do what I want, I would not, in this case at least, want to increment the values. The would always be set to 3 at XXXX hours Quote Link to comment https://forums.phpfreaks.com/topic/201705-session-time-out-questions/#findComment-1059900 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.