Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / January 2006



Tip: Looking for answers? Try searching our database.

Pull only online users from database

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TrophyUK - 31 Jan 2006 11:27 GMT
Hi,

I have a structure that logs all the live sessions on my site, normal I would
see if someone was online doing this:

#structKeyExists(Application.UsersInfo, member_id)#

What i need to do is only pull online people from the database, I cant get it
to work.  Any ieads?
TrophyUK - 31 Jan 2006 11:52 GMT
Im not tracking the users in the same way, I'm using this:

<cflock TIMEOUT="15" SCOPE="APPLICATION" TYPE="EXCLUSIVE">
    <cfif NOT isDefined("Application.UsersInfo")>
          <cfset Application.UsersInfo = StructNew()>
    </cfif>
</cflock>

<cflock NAME="#CreateUUID()#" TIMEOUT="15" TYPE="EXCLUSIVE">
      <cfset user_cfid = #getauthuser()#>
      <cfset user_time = Now()>
</cflock>

<cflock SCOPE="APPLICATION" TYPE="EXCLUSIVE" TIMEOUT="15">
 <cfif NOT StructKeyExists(Application.UsersInfo, user_cfid)>
  <cfset temp = StructInsert(Application.UsersInfo, user_cfid, user_time)>
 </cfif>
</cflock>

<cflock SCOPE="APPLICATION" TYPE="EXCLUSIVE" TIMEOUT="15">
 <cfloop COLLECTION="#Application.UsersInfo#" ITEM="itmUser">
  <cfif Evaluate(DateDiff("n", StructFind(Application.UsersInfo, itmUser),
Now())) GT 10>
    <cfset StructDelete(Application.UsersInfo, itmUser)>
  </cfif>
 </cfloop>
</cflock>

I just need to know, how in the <CFQUERY> I would check to see if the
member_id was listed in the structure.

Thanks in advance
hinsbergen - 31 Jan 2006 12:24 GMT
Why not just something like this within you <cflock>:
<cfquery name="getonlineuser" datasource="x">
SELECT userid
FROM users
WHERE username='#Application.UsersInfo.user_cfid#'
</cfquery>
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.