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>