Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Question

Status
Not open for further replies.

NetworkGuy101

IS-IT--Management
Aug 13, 2002
482
US
I have a intranet site that I use a CGI variable to get the username and determine authentication for. That way I dont have to have a login for my endusers. I would like to be able to set up a session for that username so I can somehow get a count of how many users are currenly on the site. Is this possible and if so how would I go about doing it?
 

<!----Application.cfm----->

<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 = Evaluate(CFID)>
<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>

<!----Put this in a file---->

<cflock scope="APPLICATION" type="EXCLUSIVE" timeout="10">
<cfoutput>
<center><B> Total Active Sessions : #StructCount(Application.UsersInfo)#</B></center>
</cfoutput>
</cflock>

Does this help?

Wes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top