Re: how to see all sessions sets in server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 4, 2013 at 4:00 PM, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>wrote:

>
>
> Farzan Dalaee <farzan.dalaee@xxxxxxxxx> wrote:
> >
> >
> >> On Sun, 2013-08-04 at 14:56 +0430, Farzan Dalaee wrote:
> >>>
> >>> You mean when user logged in i add new record to table and when
> >logged out i delete the row? So if user close the browser without
> >logout how can i find user is online or not?
> >>>
> >>> Sent from my iPhone
> >>>
> >>> On Aug 4, 2013, at 14:44, Matijn Woudt <tijnema@xxxxxxxxx> wrote:
> >>>
> >>> >
> >>> >
> >>> >
> >>> > On Sun, Aug 4, 2013 at 11:02 AM, Farzan Dalaee
> ><farzan.dalaee@xxxxxxxxx> wrote:
> >>> >> hi
> >>> >> i want to write online user module for my site and i want to
> >check
> >>> >> $_SESSION['userID'] to find all users id who loged in
> >>> >> but when i echo this code its return only current user detail
> >>> >> how i can see all sessions?
> >>> >>
> >>> >> foreach($_SESSION as $k => $v)
> >>> >> {
> >>> >> echo $k."----------".$v;
> >>> >> }
> >>> >>  or how i handle online users?
> >>> >
> >>> > You can only access sessions when you know the session id.
> >>> > Most sites handle online users in their database, store a
> >timestamp each time a user loads a page. When you want to display the
> >online users, check where the timestamp is between now and a few
> >minutes ago. Note that without javascript (or flash/java/etc) there is
> >no way to truly know if the user left or not. The session will stay
> >active for a long time, depending on your php.ini settings.
> >>> >
> >>> > - Matijn
> >>> >
> >>
> >> Like Matijn said, unless you're using some kind of client-side method
> >to continually poll the server, you can't know if they've just closed
> >their browser. There are Javascript events for exiting a page, but they
> >don't work correctly on Safari and iOS Safari.
> >>
> >> You don't have to actually save anything to the DB manually, just
> >instruct PHP to use the DB for its own sessions, rather than files.
> >>
> >> Do you really need to inspect each visitors session in detail, or do
> >you just need a way to determine how many unique visitors are on the
> >site at any one time?
> >>
> >> Thanks,
> >> Ash
> >> http://www.ashleysheridan.co.uk
> >>
> >>
> >>
> >
> >
> >I need to inspect each visitor to show how online or who offline for
> >chat
> >Like facebook chat
> >>
>
> Ah, so you don't need to see the details of the sessions then. Facebook
> does this (badly) by using javascript on the client side which triggers an
> update of a timestamp on the server, which then allows you to determine who
> is online (or was within a given time limit)
> Thanks,
> Ash
>

Maybe it's bad, but there's no good alternative, except sending ping
requests to your server every second or so, but any site as large as
Facebook will DDOS itself when using things like that ;)

- Matijn

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux