Re: how to see all sessions sets in server
| From: | Farzan Dalaee | Date: | Sun, 04 Aug 2013 10:26:29 +0000 |
| Subject: | Re: how to see all sessions sets in server | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-321785@lists.php.net to get a copy of this message | ||
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@gmail.com> wrote:
>
>
>
> On Sun, Aug 4, 2013 at 11:02 AM, Farzan Dalaee <farzan.dalaee@gmail.com> 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
>