rempires Posted June 20, 2007 Share Posted June 20, 2007 I know this is kind of a very broad psot, btu i'm not sure were to start with this one. I have made a user log in area for my website allows them to create/edit profile view restricted pages and all, this all works good, what i want to do is be able to show who is logged in. like phpBB and smf forums and all those ahve a users logged in. it shows who is logged in and what there viewing and stuff. manily i jsut want to tell if somone is logged and, and if i would also but able to keep track of the time there logged in this would be great. Like i said i ahve no idea were to even start with this so i'm not sure what information you would need about my loggin code, so please if i don't give required info ask for it, i'll telly ou or psot that little section of code. things that might help (kinda hit and miss until somone tells me what i need to show you guys, i don't want to post it all here, there is a lot beause i ahve suer levels and control panels for differnt levels and crap...) but log in data connect to MySQL to get user info and check and make sure it all works. then creates a session to make sure the user ahs the appropriate rights to view page is logged and and keep basic info about them as they traverse the site. My guess would be that showing what suers are logged in would ahve somthing to do with teh sessions, like if there is a way i could amke php pull all open sessions, instead of jsut teh ones for that user, but i really don't know, if you need mroe information please ask and i'll happily tell/post the code you require, i'm not asking for the code for this, btu hoiw it would work, or the functions i need... Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 20, 2007 Share Posted June 20, 2007 Sessions table in your MySQL database. That is all. Over & out. :-P Quote Link to comment Share on other sites More sharing options...
rempires Posted June 20, 2007 Author Share Posted June 20, 2007 so when they log in i just put there session in a db? but then how would i know when they logged out if they just say close the browser instead of hit the log out button. is there a function in php to check and see if that current session is active, like i put the session id into the mysql table on log-in, then i have a cron job run every 10 min to see if the sessions in it are currently active? thanks in advance, john Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted June 20, 2007 Share Posted June 20, 2007 Sure the db idea is good. But I am positive there is a php function to open all the sessions up. Try googling it. Of the 30,000 php functions, one is bound to be that one!! Quote Link to comment Share on other sites More sharing options...
rempires Posted June 20, 2007 Author Share Posted June 20, 2007 i couldn't find anything through google but in php's site i found msession_list, msession_count... unfortunitly there all undocumented, but msession_list says lsit all sessions, so this might work, thank you everyone, i will actually probably be going the database route because this way i can get a rough approximate amount of time they were on to. thanks for all your help again, john (uhh i'll mark this as solved when i figure out how...) Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 20, 2007 Share Posted June 20, 2007 If you use a sessions table, you update the session time in the database everytime a user loads a page. You then log them out if a session update time is a certain amount of time greater than the session start time. Everytime it updates it checks...etc. So it will be as accurate as you can get within a few minutes time. Quote Link to comment 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.