Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

How do i determine how many current users are on the site?

I simply want to find out how many users are currently browsing the site.  Any ideas..?

Thanx in advance...
0
hugeeuge
Asked:
hugeeuge
  • 2
1 Solution
 
seb_gibbsCommented:
Are you using an ASP or PHP server?  If so, then its possible to do this.
0
 
hugeeugeAuthor Commented:
I am using Coldfusion...
0
 
James RodgersWeb Applications DeveloperCommented:
i use this in an iframe on the pages i want teh count to appear


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
      
      <cfoutput>
            <meta http-equiv="Refresh" content="20;URL=#RELLOCPATH#users.cfm">
            <link rel="stylesheet" href="#RELLOCPATH#commonFiles/mainstyle.css" type="text/css">
      </cfoutput>
      <title>Untitled</title>
</head>

<body>

<table>
      <tr>
            <td>
                  <cfsetting enablecfoutputonly="Yes">
                        <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_info = Now()>
                        </cflock>
                        <cflock scope="APPLICATION" type="EXCLUSIVE" timeout="15">
                              <cfif NOT StructKeyExists(Application.UsersInfo, user_cfid)>
                                    <cfset temp = StructInsert(Application.UsersInfo, user_cfid, user_info)>
                              </cfif>
                        </cflock>
                        <! --- // Ok now, we have to create a way to delete them so they don't stay in the list forever, I'm going to use a 10 minutes difference, to expire the user, remember this code should be in your application.cfm or included in your application.cfm, we are going to use the DateDiff to find out if the structure should be deleted. //--->
                        <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>
                        <cflock scope="APPLICATION" type="EXCLUSIVE" timeout="15">
                              <cfoutput>
                                    <cfif #StructCount(Application.UsersInfo)# EQ 1>
                                          There is #StructCount(Application.UsersInfo)# user
                                    <cfelse>
                                          There are #StructCount(Application.UsersInfo)# users
                                    </cfif>
                                    on the system.
                              </cfoutput>
                        </cflock>
                  <cfsetting enablecfoutputonly="NO">
            </td>
      </tr>
</table>
</body>
</html>
 
0
 
James RodgersWeb Applications DeveloperCommented:
glad i could help

thanks for the points
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now