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.

    You have made the point!
    https://www.lunarciel.com/
    canada pharmacies online pharmacy
    canadian pharmacy online
    compare prescription prices
    canada pharmaceutical online ordering

  2. Your comment is awaiting moderation.

    Amazing forum posts, Thanks a lot.
    https://www.interlandchemie.com/
    prescription drugs online without doctor
    canadian pharmaceuticals online
    online pharmacies no prescription
    canadian pharmacies-24h

  3. Your comment is awaiting moderation.

    Regards, Valuable stuff.
    https://www.lunarciel.com/
    canada drugs online pharmacy
    aarp approved canadian online pharmacies
    drugs from canada
    northwestpharmacy

  4. Your comment is awaiting moderation.

    Cheers! Loads of posts.

    https://www.waltcoexpress.com/
    best non prescription online pharmacies
    canada pharmacy
    walmart pharmacy price check
    mexican pharmacies shipping to usa

  5. Your comment is awaiting moderation.

    With thanks, Lots of material.

    https://www.interlandchemie.com/
    canadian pharmacy 365
    canadian pharmaceuticals online
    online prescription drugs
    canada online pharmacies

  6. Your comment is awaiting moderation.

    Thanks. Good stuff.
    https://www.interlandchemie.com/
    rx price comparison
    canadian pharmacies that ship to us
    canadian mail order pharmacies
    online pharmacies canada

  7. Your comment is awaiting moderation.

    Nicely put. Thank you!
    https://www.interlandchemie.com/
    cheap prescription drugs
    canadian pharmacies that ship to us
    drugs without prescription
    canadian pharmacies

  8. Your comment is awaiting moderation.

    Excellent tips. Appreciate it.
    https://www.dunamisproductions.com/
    canadian prescriptions
    northwestpharmacy
    price prescription drugs
    northwest pharmacy

  9. Your comment is awaiting moderation.

  10. Your comment is awaiting moderation.

    This is nicely put. !
    https://www.waltcoexpress.com/
    no prescription pharmacies
    canada drug
    best canadian mail order pharmacies
    canadian pharmacies that ship to us

  11. Your comment is awaiting moderation.

    Information nicely utilized.!
    https://www.visitwaushara.com/
    overseas pharmacies
    canadian pharmaceuticals online
    pharmacy drug store
    canada drugs online

  12. Your comment is awaiting moderation.

    Thanks a lot! Fantastic stuff.
    https://www.lunarciel.com/
    best online pharmacy stores
    canada pharmaceuticals online
    canadapharmacyonline.com
    online pharmacies of canada

  13. Your comment is awaiting moderation.

    Nicely put. Regards!
    https://www.visitwaushara.com/
    online pharmacy no prescription needed
    aarp approved canadian online pharmacies
    mexican pharmacies shipping to usa
    canadian pharmacies

  14. Your comment is awaiting moderation.

    You actually expressed this wonderfully.
    https://www.interlandchemie.com/
    discount prescription drug
    canada online pharmacies
    canadian mail order pharmacies
    canada drugs

  15. Your comment is awaiting moderation.

    Truly loads of helpful information.
    https://www.visitwaushara.com/
    pharmacy online
    canadian pharmacies that ship to us
    get prescription online
    canada pharmacy online

  16. Your comment is awaiting moderation.

    Info very well utilized!!
    https://www.waltcoexpress.com/
    pharmacy price comparison
    canada pharmacy
    canadian pharmacies shipping to usa
    canadian drugs

  17. Your comment is awaiting moderation.

    Thanks a lot. Helpful information.
    https://www.dunamisproductions.com/
    get prescription online
    top rated canadian pharmacies online
    the canadian pharmacy
    online pharmacies canada

  18. Your comment is awaiting moderation.

    Wonderful write ups, Many thanks.
    https://www.dunamisproductions.com/
    buy cialis
    trust pharmacy canada
    online drugstore
    canadian viagra

  19. Your comment is awaiting moderation.

    Very good facts. Thank you.
    https://www.lunarciel.com/
    northwest pharmacy canada
    trust pharmacy canada
    buy prescription drugs canada
    canadian pharmacies online

  20. Your comment is awaiting moderation.

    Excellent stuff. With thanks!
    https://www.interlandchemie.com/
    canada pharmacies without script
    top rated canadian pharmacies online
    canada pharmacy online
    online pharmacies of canada

  21. Your comment is awaiting moderation.

    Factor certainly considered!!
    https://www.lunarciel.com/
    24 hour pharmacy
    canadian pharmaceuticals online
    rx online
    canadian cialis

  22. Your comment is awaiting moderation.

    Wonderful postings. Thanks!
    https://www.interlandchemie.com/
    canadian drug
    canada online pharmacies
    canadapharmacyonline.com
    northwest pharmacy

  23. Your comment is awaiting moderation.

    Awesome stuff. Thank you.
    https://www.waltcoexpress.com/
    best online pharmacies no prescription
    canada pharmacy
    canadian drug store
    london drugs canada

  24. Your comment is awaiting moderation.

    Wow many of helpful information!
    https://www.waltcoexpress.com/
    discount drugs online pharmacy
    canadianpharmacy
    mail order pharmacies
    canada pharmacy online

  25. Your comment is awaiting moderation.

    Info nicely used!.
    https://www.interlandchemie.com/
    online prescription drugs
    aarp approved canadian online pharmacies
    canada online pharmacy
    canadian pharmacies-24h

  26. Your comment is awaiting moderation.

    You said it perfectly.!
    https://www.lunarciel.com/
    compare prescription prices
    canadian pharmacies online
    pharmacy without dr prescriptions
    canadian viagra

  27. Your comment is awaiting moderation.

    Nicely put. With thanks!
    https://www.visitwaushara.com/
    global pharmacy canada
    canada pharmacy online
    buying drugs canada
    canada pharmacy

  28. Your comment is awaiting moderation.

    You actually mentioned it well.
    https://www.dunamisproductions.com/
    canadian pharmacies that are legit
    trust pharmacy canada
    canadian drugstore
    canada drugs

  29. Your comment is awaiting moderation.

    Beneficial tips. Cheers!
    https://www.interlandchemie.com/
    safe canadian online pharmacies
    canadian online pharmacy
    pharmacies near me
    online pharmacies of canada

  30. Your comment is awaiting moderation.

    Nicely put. Appreciate it!
    https://www.dunamisproductions.com/
    canadian pharmacies top best
    online pharmacies of canada
    canadian rx pharmacy online
    northwestpharmacy

  31. Your comment is awaiting moderation.

    Good posts. Cheers!
    https://www.lunarciel.com/
    24 hour pharmacy
    canadian pharmacies that ship to us
    canadian prescription drugstore
    mexican pharmacies shipping to usa

  32. Your comment is awaiting moderation.

    Regards, Lots of data!

    https://www.visitwaushara.com/
    pharmacy online store
    canada drugs online
    canadian online pharmacy
    london drugs canada

  33. Your comment is awaiting moderation.

    Kudos. I appreciate it.
    https://www.dunamisproductions.com/
    canadian pharmacy no prescription needed
    canada drug
    online pharmacies canada
    northwest pharmacy

  34. Your comment is awaiting moderation.

    Factor clearly taken!!
    https://www.dunamisproductions.com/
    canadian prescription
    global pharmacy canada
    online prescription drugs
    canadian cialis

  35. Your comment is awaiting moderation.

    Amazing tons of wonderful tips!
    https://www.lunarciel.com/
    walgreens pharmacy
    canadian pharmacy online
    legitimate canadian mail order pharmacies
    canadian pharmaceuticals online

  36. Your comment is awaiting moderation.

    Seriously tons of superb data!
    https://www.lunarciel.com/
    canadian pharmacy online
    canadian online pharmacies
    drugstore online
    canadian cialis

  37. Your comment is awaiting moderation.

    Thank you, An abundance of knowledge!

    https://www.lunarciel.com/
    prescription drugs prices
    canada pharmaceuticals online
    canadian pharmacies without prescriptions
    mexican pharmacies shipping to usa

  38. Your comment is awaiting moderation.

    Incredible many of good data.
    https://www.waltcoexpress.com/
    most reliable canadian pharmacies
    canadianpharmacy
    canadian pharmacy
    canadian pharmacy online

  39. Your comment is awaiting moderation.

    Wow many of very good tips!
    https://www.lunarciel.com/
    best online pharmacies canada
    canadian pharmacy
    mexican pharmacy online
    canada online pharmacies

  40. Your comment is awaiting moderation.

    With thanks! An abundance of postings.

    https://www.lunarciel.com/
    best non prescription online pharmacies
    canada drugs
    mail order pharmacy
    trust pharmacy canada

  41. Your comment is awaiting moderation.

    You explained this really well!
    https://www.lunarciel.com/
    canadian drugs
    canada drugs online
    buy prescription drugs without doctor
    canadian pharcharmy

  42. Your comment is awaiting moderation.

    Lovely info, Cheers!
    https://www.interlandchemie.com/
    northwest pharmacy canada
    canada pharmacy online
    international pharmacy
    top rated canadian pharmacies online

  43. Your comment is awaiting moderation.

    You mentioned this very well.
    https://www.dunamisproductions.com/
    drugs online
    mexican pharmacies shipping to usa
    buy prescription drugs online
    trust pharmacy canada

  44. Your comment is awaiting moderation.

    Very good material. Many thanks.
    https://www.waltcoexpress.com/
    canadian pharma companies
    canadian viagra
    canada drugs online
    northwest pharmacy

  45. Your comment is awaiting moderation.

    You made your stand very clearly!!
    https://www.dunamisproductions.com/
    no 1 canadian pharcharmy online
    canada drugs
    pharmacy cost comparison
    canadian pharmacies without an rx

  46. Your comment is awaiting moderation.

    You suggested it exceptionally well.
    https://www.lunarciel.com/
    canadian pharcharmy online
    canadian cialis
    ed meds online
    aarp approved canadian online pharmacies

  47. Your comment is awaiting moderation.

    Seriously a lot of beneficial tips!
    https://www.waltcoexpress.com/
    rx price comparison
    canadian pharmacies that ship to us
    prescription drug
    canadian pharmacies online

  48. Your comment is awaiting moderation.

    Fine posts. Thanks a lot!
    https://www.waltcoexpress.com/
    international pharmacies that ship to the usa
    canadian pharmacies-24h
    buy prescription drugs without doctor
    canadian pharmacy online

  49. Your comment is awaiting moderation.

    Cheers! Wonderful information.
    https://www.dunamisproductions.com/
    canadian pharmacy king
    canadian pharmacies without an rx
    prescription cost comparison
    canadian pharmacies-24h

  50. Your comment is awaiting moderation.

  51. Your comment is awaiting moderation.

    You explained that terrifically!
    https://www.visitwaushara.com/
    canadadrugs.com pharmacy
    canada online pharmacies
    global pharmacy canada
    canadian pharmacy

  52. Your comment is awaiting moderation.

    Incredible lots of beneficial information.
    https://www.interlandchemie.com/
    best online pharmacies canada
    canada drugs online
    prescription drugs without prior prescription
    northwest pharmacy

  53. Your comment is awaiting moderation.

    Seriously plenty of valuable data.
    http://canadianpharmacyntx.com/
    canadian pharma companies
    online pharmacies of canada
    pharmacy online
    canada online pharmacies

  54. Your comment is awaiting moderation.

    Thanks a lot, I enjoy it!
    http://talahicc.com/
    highest rated canadian pharmacies
    canada pharmaceuticals online
    pharmacy online store
    trust pharmacy canada

  55. Your comment is awaiting moderation.

    Wonderful material. Appreciate it.
    http://talahicc.com/
    mexican pharmacy online
    canadian pharmaceuticals online
    best price prescription drugs
    canadian pharmacies

  56. Your comment is awaiting moderation.

    Very good data, Cheers!
    http://talahicc.com/
    canadian pharmacy uk delivery
    mexican pharmacies shipping to usa
    medical information online
    canada online pharmacies

  57. Your comment is awaiting moderation.

    You expressed that terrifically.
    http://canadianpharmacymim.com/
    discount prescription drugs online
    aarp approved canadian online pharmacies
    buy prescription drugs without doctor
    canadian pharmacy

  58. Your comment is awaiting moderation.

    Kudos! Lots of info!

    http://canadianpharmacysilo.com/
    buy prescription drugs canada
    canadian cialis
    buying drugs canada
    canadian pharmacies that ship to us

  59. Your comment is awaiting moderation.

    You said it perfectly.!
    http://canadianpharmacysilo.com/
    discount pharmacy online
    north west pharmacy canada
    trusted overseas pharmacies
    canada pharmacy online

  60. Your comment is awaiting moderation.

    Whoa loads of fantastic knowledge.
    http://www.canadianpharmacymsn.com/
    mexican pharmacies online
    canada pharmacy
    canadian online pharmacies prescription drugs
    canada drug

  61. Your comment is awaiting moderation.

    Many thanks. A good amount of facts.

    http://canadianonlinepharmacynnm.com/
    canadian prescription drugstore
    canadian online pharmacies
    canadian prescription drugs
    canadian pharmacies online

  62. Your comment is awaiting moderation.

    Very good postings, Thank you!
    http://canadianpharmacyntx.com/
    no prior prescription required pharmacy
    online pharmacies canada
    cheap prescription drugs online
    canada online pharmacies

  63. Your comment is awaiting moderation.

    Thanks. Quite a lot of material.

    http://talahicc.com/
    canada drug pharmacy
    canadian pharmacies without an rx
    canada drugs pharmacy
    canadian drugs

  64. Your comment is awaiting moderation.

    Amazing stuff. Thanks a lot.
    http://canadianpharmacymim.com/
    onlinecanadianpharmacy.com
    canada pharmacy
    canadian rx pharmacy online
    canadian online pharmacy

  65. Your comment is awaiting moderation.

    Thanks, I like this!
    http://talahicc.com/
    online pharmacy no prescription needed
    canadian online pharmacies
    canada drugs pharmacy
    canada pharmaceutical online ordering

  66. Your comment is awaiting moderation.

    Excellent stuff. Thanks.
    https://nicktambone.com/
    mexican pharmacy online
    canadian cialis
    cialis canadian pharmacy
    canada online pharmacies

  67. Your comment is awaiting moderation.

    You made the point.
    http://canadianpharmacysilo.com/
    pharmacy canada
    online pharmacies canada
    price prescription drugs
    canada pharmaceuticals online

  68. Your comment is awaiting moderation.

    Nicely put, Thanks a lot!
    http://canadianpharmaciescubarx.com/
    online prescription drugs
    canadian cialis
    cialis canadian pharmacy
    canadian online pharmacy

  69. Your comment is awaiting moderation.

    Nicely put. Many thanks.
    http://canadianpharmaciesnnm.com/
    canadian pharmacy viagra brand
    north west pharmacy canada
    mexican pharmacy online
    online pharmacies of canada

  70. Your comment is awaiting moderation.

    Reliable posts. Thank you.
    https://nicktambone.com/
    mexican pharmacy online
    global pharmacy canada
    best online international pharmacies
    mexican pharmacies shipping to usa

  71. Your comment is awaiting moderation.

    You actually expressed that very well!
    http://canadianpharmacysilo.com/
    drugstore online
    mexican pharmacies shipping to usa
    web medical information
    canadian pharmacies that ship to us

  72. Your comment is awaiting moderation.

    Good material. With thanks!
    https://nicktambone.com/
    prescription cost comparison
    canada online pharmacies
    canadianpharmacy
    north west pharmacy canada

  73. Your comment is awaiting moderation.

    Amazing a lot of amazing tips!
    http://canadianpharmaciescubarx.com/
    canadian pharma companies
    canadian pharmacies online
    online pharmacy without a prescription
    online pharmacies of canada

  74. Your comment is awaiting moderation.

    You mentioned this really well!
    http://canadianpharmacyntx.com/
    prescription price comparison
    canada pharmacy
    prescription cost
    aarp approved canadian online pharmacies

  75. Your comment is awaiting moderation.

    Beneficial facts. Appreciate it!
    http://talahicc.com/
    pharmacy prices compare
    canadian online pharmacies
    online canadian pharmacies
    canada online pharmacies

  76. Your comment is awaiting moderation.

    You revealed this wonderfully!
    http://canadianonlinepharmacynnm.com/
    pain meds online without doctor prescription
    mexican pharmacies shipping to usa
    canadian drug store
    canada pharmacy online

  77. Your comment is awaiting moderation.

    Factor clearly regarded..
    http://canadianpharmacysilo.com/
    canada pharmacies prescription drugs
    canadian pharmacies without an rx
    board of pharmacy
    canadian online pharmacy

  78. Your comment is awaiting moderation.

    Many thanks. Ample forum posts.

    http://canadianpharmaciescubarx.com/
    drug costs
    canada pharmacy online
    canada pharmacy online
    northwestpharmacy

  79. Your comment is awaiting moderation.

    You made your point!
    http://canadianpharmacyntx.com/
    buying prescription drugs canada
    top rated canadian pharmacies online
    web medical information
    canadian online pharmacy

  80. Your comment is awaiting moderation.

    Wow all kinds of superb info!
    https://nicktambone.com/
    canadian drug
    canadian drugs
    buying prescription drugs canada
    canadian cialis

  81. Your comment is awaiting moderation.

    Whoa loads of helpful facts.
    http://canadianonlinepharmacynnm.com/
    international pharmacies that ship to the usa
    canadian cialis
    prescription cost
    canadian viagra

  82. Your comment is awaiting moderation.

  83. Your comment is awaiting moderation.

    Thank you, Very good stuff.
    http://canadianpharmacymim.com/
    canada pharmacies online prescriptions
    canadian pharmaceuticals online
    best online international pharmacies
    northwest pharmacy

  84. Your comment is awaiting moderation.

    Regards! A lot of posts!

    http://www.canadianpharmacymsn.com/
    canadian pharmacy reviews
    online pharmacies canada
    pharmacy cost comparison
    canadianpharmacy

  85. Your comment is awaiting moderation.

    With thanks! Quite a lot of write ups.

    http://canadianonlinepharmacynnm.com/
    canadian online pharmacies prescription drugs
    canadian pharmacies that ship to us
    international pharmacies that ship to the usa
    canada online pharmacies

  86. Your comment is awaiting moderation.

    With thanks! I enjoy this.
    http://canadianpharmaciescubarx.com/
    ed meds online
    canadian viagra
    web medical information
    canadian pharmacies-24h

  87. Your comment is awaiting moderation.

    Regards. I appreciate this!
    http://canadianpharmaciescubarx.com/
    canada pharmacies without script
    canadian pharmacy online
    canadian pharmacy 365
    northwest pharmacy

  88. Your comment is awaiting moderation.

    Nicely put, Thanks a lot.
    http://canadianpharmacysilo.com/
    visit poster’s website
    canadian online pharmacies
    canadian drug
    trust pharmacy canada

Leave a Reply

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