/* in the Application.cfm */

// if user logging struct isn't there, make it so
if (not isDefined('application.user')) {
        application.user = structNew() ;
        }

// insert user's id and current time (for last access calcs)
structInsert(application.user, session.uuid, now()) ;




/* on the display page */

// run through all the users that are logged in
for (u in application.user) {

        // if user's last access is older than their session timeout, remove them
        if (dateCompare(application.user[u], dateAdd('n', -20, now()), 'n') lt 1) {
                structDelete(application.user, u) ;

        // else they might still be logged in, show them as such
        }else{
                writeOutput(u & application.user[u]) ;
                }
        }


This is only to illustrate the concept, you'll want to do some heavy editing
before you use it: Locking, copying to local vars for display, etc. are all
things to consider. I have no idea the number of users you expect, etc. so
you'll have to decide if this is right for you.


-----Original Message-----
From: W Luke [mailto:[EMAIL PROTECTED]]
Sent: March 31, 2001 08:41
To: CF-Talk
Subject: Re: Seeing who's logged in



Not sure I fully understand - could you show me an example bit of code?  I'm
still not familiar with structures.

Cheers

Will

> Yep, using the application scope just set a var in a struct (their id as
> key, now() as value) then clean it up for all entries
dateAdd('n', -<session
> timeout>, now()) and you'll have a pretty good idea of who's logged in
(w/in
> the session timeout limit). Just make sure to lock the scope properly, you
> can also do this db in the client vars if you want.
>
> -----Original Message-----
> From: Yoshi Melrose [mailto:[EMAIL PROTECTED]]
> Sent: March 30, 2001 16:17
> To: CF-Talk
> Subject: Re: Seeing who's logged in
>
>
> Wouldn't session variables work for this? That's what I've used in the
past
> for anything that was sensitive to browser sessions. I know they're kinda
> flaky sometimes, which is why I try not to use them.
>
> Any other ideas? I'd like to know any other suggestions as well, sounds
like
> something I could integrate into one of my own apps.
>
> ----- Original Message -----
> From: "W Luke" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Friday, March 30, 2001 5:29 PM
> Subject: Seeing who's logged in
>
>
> > Hi,
> >
> > On one of my sites users log in, and client.email is set - for the
> > members-only sections, it then checks to see if client.email is set and
> lets
> > them in (or tells them to login) accordingly.  How can I add a "Who's
> > online" section..to display which users are currently logged in? Because
> > even if the user closes their browser, won't their token/cfid still be
in
> > the Database and therefore they'll appear "online" even though they're
> not?
> > Or have I lost the plot...(run out of Red Bull...coffee just doesn't do
> > it...)
> >
> > Will
> > --
> > [EMAIL PROTECTED] -=- www.lukrative.com
> > Local-Advertising -=- www.localbounty.com
> >
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to