Who’s online on your Site

The are many tutorials on the Internet that will show how many active users are
on a website. Here is one – http://www.4guysfromrolla.com/webtech/061399-2.shtml
. But, it can be a bit trickier to extend this to give a list of the active users.
In the example I going to show you, I will store the users in an XML file. This
method may not be perfect, but may suit the needs of many.

After a user logs in, we can store their details in XML. The file below can
be included in each page. All the demo files can be downloaded from link at
the bottom of the page. When a page is loaded the following actions are performed:

1.
The XML is loaded from disk (the folder containing the XML file must have
the correct permissions to write to it)
2. Users are removed from the file that haven’t visited a page in the last
5 minutes (this is stored in the UserTimeout variable and can be changed)
3. Any reference to the current user is also removed.
4. A timestamp is added for the current user.
5. The XML file is then saved to disk.

Another include file is then used to show the users. This is included in the
demo files below.

<%
'This file goes on every page that is is protected
Session.LCID=2057
XmlFile=Server.MapPath("xml/users.xml")
Username=Session("MM_Username")
UserTimeout=5 'A 5 minute timeout seems reasonable
ExpiryDate=IsoFormat(dateadd("n",-UserTimeout,Now))

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.load(XmlFile)
set objNodeXML=objXML.documentElement
RemoveOldNodes
RemoveUserNodes
AddUserNode
objXML.Save XmlFile
Set objXML = Nothing

function RemoveOldNodes
	set OldNodes=objNodeXML.selectNodes("user[@date < '" & ExpiryDate & "']")
	if IsObject(OldNodes) then
		for each nd in OldNodes
			objNodeXML.removeChild(nd)
		next
	end if
end function

function RemoveUserNodes
	set CurrentUserNodes=objNodeXML.selectNodes("user[@username='" & Username & "']")
	if IsObject(CurrentUserNodes) then
		for each nd in CurrentUserNodes
			objNodeXML.removeChild(nd)
		next
	end if
end function

function AddUserNode
	set newNode=objXML.createNode(1,"user","")
	newNode.setAttribute "username",Username
	newNode.setAttribute "date",IsoFormat(now)
	objNodeXML.appendChild(newNode)
end function

function IsoFormat(t)
	IsoFormat=year(t) & FormatDT(month(t)) & FormatDT(day(t)) & FormatDT(Hour(t)) & FormatDT(minute(t)) & FormatDT(second(t))
end function

function FormatDT(o)
	if len(o)=1 then
		FormatDT="0" & o
	else
		FormatDT=o
	end if
end function
%>
Updated: March 6, 2015 — 5:16 pm

Comments

Add a Comment
  1. Your comment is awaiting moderation.

    Factor well utilized..

    purchase viagra in australia viagra type products
    viagra online
    wanda sykes viagra – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  2. Your comment is awaiting moderation.

    You actually stated this wonderfully.

    grneric viagra i want to try viagra
    viagra without a doctors prescription
    what is viagra used for – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  3. Your comment is awaiting moderation.

  4. Your comment is awaiting moderation.

    Valuable posts. Kudos!

    lorazepam viagra consumer coplaints against netdr viagra
    viagra for women
    viagra in vietnam – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  5. Your comment is awaiting moderation.

    Terrific postings. Many thanks!

    what is viagra made of file viewtopic t 21508 viagra
    buy generic viagra
    find search viagra free sites computer – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  6. Your comment is awaiting moderation.

    Regards! I enjoy this.

    chinese viagra 5 venetian las vegas information viagra
    generic viagra 100mg
    viagra or cilas – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  7. Your comment is awaiting moderation.

    Superb write ups. Kudos!

    watermelon viagra connection bonifacio comandante viagra
    generic viagra online
    viagra retail discoun – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  8. Your comment is awaiting moderation.

    Truly lots of awesome knowledge.

    is there any legitimate viagra vicodin viagra cialis
    generic viagra
    generic viagra lowest prices – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  9. Your comment is awaiting moderation.

    This is nicely expressed! !

    generic viagra blog file viewtopic t 21508 viagra
    generic viagra 100mg
    re buy viagra – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  10. Your comment is awaiting moderation.

    You made your stand extremely effectively!!

    viagra multiple chemical sensitivities natural foods that sub viagra affects
    buy viagra
    topical viagra for women – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  11. Your comment is awaiting moderation.

    Thanks. I like it!

    viagra 100mg 4 tablet blister pack open label viagra and antidepressant study
    generic viagra 100mg
    wal-mart viagra price – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  12. Your comment is awaiting moderation.

    Kudos, Terrific stuff.

    viagra generic wholesale generic viagra online without prescription
    viagra pills
    viagra partial dose – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  13. Your comment is awaiting moderation.

    Nicely put. Cheers!

    viagra online free buy levitra online viagra
    viagra online
    target google viagra order cheap – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  14. Your comment is awaiting moderation.

    Amazing tons of terrific tips!

    generic viagra amex viagra or ciallis
    viagra 100mg
    viagra and heart attack – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  15. Your comment is awaiting moderation.

    You said it nicely.!

    ups shipping viagra distribution channel of viagra
    buy generic viagra
    tga and viagra – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  16. Your comment is awaiting moderation.

    Fine info. Appreciate it!

    jeff johnson viagra viagra light switch plate
    viagra for women
    viagra antidepressants – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  17. Your comment is awaiting moderation.

    You said it adequately.!

    ap viagra hearing loss disease viagra heart
    buy viagra
    viagra before and after photos – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  18. Your comment is awaiting moderation.

    You said it nicely..

    www viagra dog viagra
    viagra for sale uk
    isosorb viagra interactions – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  19. Your comment is awaiting moderation.

    Whoa lots of fantastic info!

    fake viagra viagra nasal spray
    viagra pills
    purchase generic viagra online – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  20. Your comment is awaiting moderation.

    Wonderful write ups. With thanks!

    viagra rx pharmacy viagra impotence pill
    generic viagra
    viagra action – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  21. Your comment is awaiting moderation.

    Appreciate it! Quite a lot of knowledge.

    viagra kamagra cheap endowmax viagra
    generic viagra online
    viagra plus cialis – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  22. Your comment is awaiting moderation.

    Awesome info. Kudos.

    hot sauce texas viagra real viagra paypal
    generic viagra 100mg
    distortion viagra – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  23. Your comment is awaiting moderation.

    Excellent data. Thanks.

    viagra health risks viagra drink recipe
    generic viagra 100mg
    lowest prices viagra uk – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  24. Your comment is awaiting moderation.

    Amazing tons of very good tips!

    viagra prescription cost buy herbal viagra longer erections
    generic viagra 100mg
    viagra embarrasing stories – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  25. Your comment is awaiting moderation.

  26. Your comment is awaiting moderation.

    This is nicely expressed. .

    free viagra program pfizer viagra webpage
    viagra generic
    target pharmacy viagra – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  27. Your comment is awaiting moderation.

    You actually revealed this fantastically.

    viagra elvis commercial viagra instructions
    viagra generic
    viagra recommended dosage – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  28. Your comment is awaiting moderation.

    You’ve made your stand very well!.

    buying viagra in spain watermelon rines and viagra
    viagra for sale uk
    viagra half price generix – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  29. Your comment is awaiting moderation.

    You made your position extremely clearly!.

    cheapest generic viagra cialis pills zapiro cartoon viagra
    buy generic viagra
    pharmacy silagra generic viagra cumwithuscom – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  30. Your comment is awaiting moderation.

    Cheers! An abundance of material.

    can i take viagra price of viagra
    buy generic viagra
    best deals on viagra – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  31. Your comment is awaiting moderation.

    Cheers, A lot of info!

    dirt cheap viagra viagra home depot price
    buy generic viagra
    premature orgasm with viagra – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  32. Your comment is awaiting moderation.

    Point nicely utilized..

    generic viagra canadian edinburgh viagra tid search charles
    generic viagra 100mg
    viagra industry sales – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  33. Your comment is awaiting moderation.

    Wonderful data. Appreciate it.

    viagra edinburgh search cartoons charles amiodarone and viagra
    buy generic viagra
    buy viagra in the philippines – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  34. Your comment is awaiting moderation.

    With thanks! A good amount of material.

    out of date viagra viagra cialis levitra online rxmeds
    viagra for sale uk
    polish viagra – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  35. Your comment is awaiting moderation.

    Appreciate it. An abundance of info!

    banned viagra commercials viagra power jamaican comedy
    viagra generic
    viagra alternative and woman – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  36. Your comment is awaiting moderation.

    Thank you! Excellent information!

    medical journals pulmonary hypertension viagra nhs prices viagra uk
    generic viagra
    effects side viagra – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  37. Your comment is awaiting moderation.

  38. Your comment is awaiting moderation.

    Many thanks. Lots of facts.

    does viagra help stress induced ed viagra find sites search computer
    viagra pills
    viagra controlled substance – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  39. Your comment is awaiting moderation.

  40. Your comment is awaiting moderation.

    Kudos, Helpful information!

    viagra and sinusitis viagra commercial saturday night live
    buy generic viagra
    viagra following prostate surgery – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

  41. Your comment is awaiting moderation.

    Thanks! Terrific stuff!

    medical info on viagra naked viagra cartoons
    generic viagra 100mg
    tenuate vs viagra – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  42. Your comment is awaiting moderation.

    You stated it superbly.

    don’t mix viagra wih steroids photo viagra phuket
    generic viagra
    viagra prescription on line – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  43. Your comment is awaiting moderation.

    Regards, A good amount of posts!

    viagra results videos free viagra si
    viagra 100mg
    buy generic viagra cheap – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  44. Your comment is awaiting moderation.

    Regards. I like this!

    cialis europe viagra plavix and viagra
    cheap viagra
    which is better cialis soft or viagra – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  45. Your comment is awaiting moderation.

    Thanks a lot! I value it!

    viagra tv commercials sustiva viagra
    buy viagra
    ordering viagra from uk reviews – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  46. Your comment is awaiting moderation.

    Really a lot of awesome knowledge!

    purchase viagra without prescription viagra delivered on saturday by fedex
    viagra online
    search viagra viagra find 76k buy – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  47. Your comment is awaiting moderation.

    Cheers! Quite a lot of information.

    what are the ingredients in viagra youngest person to use viagra
    buy viagra online
    viagra cheap pharmacy – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  48. Your comment is awaiting moderation.

  49. Your comment is awaiting moderation.

  50. Your comment is awaiting moderation.

    Whoa lots of helpful tips!

    joke viagra sites computer viagra find edinburgh free
    generic viagra
    viagra contest – https://genericviagramsl.com

    KeithBob
    Richardinigo
    Ernestosworo

  51. Your comment is awaiting moderation.

    Regards, Ample info.

    viagra cialis london kamagra lorazepam interaction with viagra
    viagra without a doctor prescription
    fucked like a teenager viagra – https://genericviagrantx.com

    KeithBob
    Richardinigo
    Ernestosworo

  52. Your comment is awaiting moderation.

    Thanks! Awesome stuff!

    viagra cheap pills find search viagra ago edinburgh hours
    viagra without a doctors prescription
    where to get viagra – https://genericviagrarcp.com

    KeithBob
    Richardinigo
    Ernestosworo

Leave a Reply

Your email address will not be published. Required fields are marked *