On this new website i'm making I use sessions for users to log in. I also have it so it shows who all the users are that are online and where they are and for how long etc...

Well I got this much working by storeing the page they are on, username, and there last active date in a database and I update the date everytime they go to a page. If they don't have any activity for so long it deletes them from the database.

My problem with this is to find a good way that I can make it automaticly remove them from the database if they close there browser window? I was thinking of useing a javascript pop-up that will remove them from the database when they leave the site then auto close it after. Is this the best way? I think this is what I seen other sites do...

Is there any way to tap right into the session data on the server to tell who's online?

what is the best way to do this?

Thanks

    I guess what i'm trying to ask basicly is what's the best way to tell PHP that you closed your browser or left your website?

      uh, with sessions, I believe they automatically end when the associated browser window is closed, unless you have them set to keep going for a particular period of time.

      So you should just be able to run a cron job checking to see which sessions are still active.

      PS - people get really cranky around here for bumping threads. if no one responded, no one responded, but don't add comments just to get back at the top of the list. especially after only an hour. plenty of us log on and look for threads with zero responses. having a response, even your own, makes it look sometimes like someone's already helping...

        Ok, well how would I be able to go though and see what sessions are active or in-active? that's my problem.

          Well, thats a good question. Afraid I don't know the answer myself, but the manual can probably give you clues some here.

          cheers

            I read over all that. The the only thing I figured out was that you can change the path of where the server stores the session data and I figure if I change the path to somewhere that I can get to it with my script and decode it or whatever and figure out what users are online.

            I haven't tried this yet and I don't know the format of the data when I am able to get to it. Also I figured there would be a lot of security problems with it. Anyone know about this at all?

            I tried out pop-ups but it's hard to find one that pops up only when the person leaves the domin or closes the browser and on top of that most people seem to have pop-up blockers so that doesn't seem to work well.

            If I can't figure out how i'll probably just put a 15 min or so timer on it, after that it shows the person as offline.

              Write a Reply...