/    Sign up×
Community /Pin to ProfileBookmark

New query – display all logged in users?

Hiya.
New query for you please. ?

We have a login system on our site which is based mostly on PHP sessions, but also uses cookies for the login date and time.

From our login.php upon a successful login the following is set:

[code=php]
$_SESSION[‘logged’] = true;
$_SESSION[‘account’] = $account;
$_SESSION[‘password’] = $password;
$_SESSION[‘ip’] = $_SERVER[‘REMOTE_ADDR’];
setcookie(‘logindate’, date(‘d/m/Y’));
setcookie(‘logintime’, date(‘H:i:s’));
[/code]

The actual data is stored in a users.txt flatfile db which is protected, and has a layout of:

[code]user,md5pass[/code]

I can paste the entire code if it helps.

My query though is it possible based on this flatfile to create an ‘online.php’ which will show all active users who are logged in (have the ‘logged’ session var) and say what their session age has been based on the cookie? If it’s too difficult with the session age that’s not a problem, but it would be nice for the users who are logged in to be displayed in a ul/li format.

Any advice on this will be much appreciated. ?
Thanks.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@aznchong91Aug 30.2005 — Can't you just read each line from the file?
Copy linkTweet thisAlerts:
@DanUKauthorAug 30.2005 — Hiya.

Thanks for your reply.

If I read from that users.txt it will just display all the users in our database, right? What we want is to be able to show which members are logged in (that have the logged session var set).
Copy linkTweet thisAlerts:
@DanUKauthorAug 31.2005 — Any ideas on this please?

Thanks.?
×

Success!

Help @DanUK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...