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.

    Seriously all kinds of superb information!
    http://cialismsnntx.com/
    cost of cialis for daily use
    cialis 20 mg
    effet cialis pГ©rimГ©
    cheap cialis

  2. Your comment is awaiting moderation.

    Kudos. I enjoy it!
    http://cialismsnntx.com/
    how much is cialis daily
    cialis generic
    cheap cialis generic canada
    cheap cialis

  3. Your comment is awaiting moderation.

    Reliable postings. Cheers!
    http://cialismsnntx.com/
    pakistani cialis generic
    cheap cialis
    wtf is cialis
    generic cialis

  4. Your comment is awaiting moderation.

    You made your point.
    http://cialismsnntx.com/
    dove comprare il cialis su internet
    buy cialis online
    cialis kupnja
    cialis 20mg

  5. Your comment is awaiting moderation.

    Thanks a lot! Quite a lot of write ups.

    http://cialisttk.com/
    cialis schwarzmarkt
    generic cialis
    can i mix cialis and viagra
    buy cialis online

  6. Your comment is awaiting moderation.

    You actually suggested that wonderfully!
    https://www.cialisfidel.com/
    cialis aumenta il desiderio
    cheap cialis
    cialis eczane fiyatД± 2013
    cialis 20 mg

  7. Your comment is awaiting moderation.

    Thank you, Loads of facts.

    http://cialismsnrx.com/
    cialis first time users
    cialis without a doctor prescription
    which is better levitra or cialis
    buy cialis online

  8. Your comment is awaiting moderation.

    Thank you! Fantastic information!
    https://www.cialisfidel.com/
    cialis avant ou apres manger
    cialis online
    les bienfaits du cialis
    cialis 20 mg

  9. Your comment is awaiting moderation.

    Thanks a lot, I like it.
    https://www.cialisfidel.com/
    fausse ordonnance pour du cialis
    cialis online
    harga cialis 80 mg
    cialis generic

  10. Your comment is awaiting moderation.

    Nicely put, Cheers.
    http://cialispego.com/
    cialis presentaciones precio
    cialis online
    how long before cialis for daily use works
    cialis without a doctor prescription

  11. Your comment is awaiting moderation.

    Thank you. Useful information!
    http://cialispego.com/
    cialis kautabletten nebenwirkungen
    generic cialis
    cialis sus efectos
    cialis online

  12. Your comment is awaiting moderation.

    Thank you! I like this!
    https://www.cialisfidel.com/
    effet viagra et cialis
    cialis 20 mg
    dosis maksimal cialis
    cialis 20mg

  13. Your comment is awaiting moderation.

    Wonderful forum posts. Regards.
    https://www.cialismim.com/
    was ist in cialis drin
    cialis without a doctor prescription
    se puede comprar cialis en andorra
    cheap cialis

  14. Your comment is awaiting moderation.

    Nicely expressed really. .
    http://cialismsnntx.com/
    generic cialis black (tadalafil)
    buy cialis online
    can you take cialis with prednisone
    generic cialis

  15. Your comment is awaiting moderation.

    Really all kinds of great advice.
    http://cialismsnntx.com/
    wo kann man cialis sicher kaufen
    buy cialis online
    cialis and viagra together
    cheap cialis

  16. Your comment is awaiting moderation.

    Superb knowledge. Many thanks.
    http://cialispego.com/
    cialis 20mg pharmacie france
    buy cialis online
    order cialis safely online
    cialis 20 mg

  17. Your comment is awaiting moderation.

    Kudos, A lot of facts.

    https://www.cialisfidel.com/
    quel est meilleur site pour acheter cialis
    cheap cialis
    cialis dor muscular
    cialis 20 mg

  18. Your comment is awaiting moderation.

    Incredible a lot of amazing advice!
    http://cialismsnrx.com/
    site commande cialis
    cialis generic
    serve prescrizione per cialis
    cheap cialis

  19. Your comment is awaiting moderation.

    Very well expressed without a doubt! .
    http://cialispego.com/
    cialis paid by insurance
    buy cialis online
    effets secondaires de cialis
    generic cialis

  20. Your comment is awaiting moderation.

    Kudos. I enjoy it.
    https://www.cialismim.com/
    what insurance plans cover cialis
    generic cialis
    viagra cialis kup
    cheap cialis

  21. Your comment is awaiting moderation.

    Factor nicely regarded.!
    http://cialismsnntx.com/
    prix cialis en pharmacie paris
    cialis online
    cialis 5000
    buy cialis online

  22. Your comment is awaiting moderation.

    Amazing tons of fantastic info!
    https://www.cialisfidel.com/
    can a healthy man take cialis
    cheap cialis
    cialis per nachnahme ohne rezept
    cialis 20mg

  23. Your comment is awaiting moderation.

    Kudos! A good amount of information!

    https://www.cialismim.com/
    cialis vs viagra dosages
    buy cialis online
    vanzari viagra cialis
    generic cialis

  24. Your comment is awaiting moderation.

    You’ve made your stand quite nicely!.
    http://cialispego.com/
    para comprar cialis precisa receita
    cialis 20mg
    cialis 20mg filmtabletten wirkung
    generic cialis

  25. Your comment is awaiting moderation.

    Nicely put. Thanks!
    http://cialispego.com/
    cialis 20mg original france
    buy cialis online
    what is with the bathtubs in the cialis commercials
    cialis 20mg

  26. Your comment is awaiting moderation.

    Thanks! I value this!
    https://www.cialisfidel.com/
    reacciones de cialis
    cialis 20 mg
    taking 20mg of cialis
    cheap cialis

  27. Your comment is awaiting moderation.

    Amazing all kinds of useful material.
    http://cialismsnntx.com/
    vrai cialis lilly
    cialis 20mg
    cialis e psa
    cialis 20 mg

  28. Your comment is awaiting moderation.

    You suggested this exceptionally well.
    http://cialispego.com/
    quando devo tomar o cialis
    cialis without a doctor prescription
    cialis generico de india
    cialis without a doctor prescription

  29. Your comment is awaiting moderation.

    You made your stand quite nicely.!
    http://cialispego.com/
    cialis kaufen 24
    cheap cialis
    alprazolam cialis
    buy cialis online

  30. Your comment is awaiting moderation.

    Thanks. Very good stuff!
    https://www.cialisfidel.com/
    cialis et tribulus
    generic cialis
    cialis biljni iskustva
    cialis generic

  31. Your comment is awaiting moderation.

    Superb posts. Thanks.
    https://www.cialismim.com/
    response time for cialis
    cialis generic
    cialis free offers
    generic cialis

  32. Your comment is awaiting moderation.

    Terrific info. Regards.
    http://cialispego.com/
    cialis due giorni consecutivi
    buy cialis online
    cialis a quoi Г§a sert
    cialis 20mg

  33. Your comment is awaiting moderation.

    Seriously a good deal of terrific advice!
    http://cialismsnntx.com/
    cialis pre workout
    cialis without a doctor prescription
    how long until cialis expires
    cheap cialis

  34. Your comment is awaiting moderation.

    You actually explained this adequately!
    https://www.cialismim.com/
    wo kaufe ich cialis generika
    cialis generic
    how much does once daily cialis cost
    generic cialis

  35. Your comment is awaiting moderation.

    Fantastic facts, Appreciate it!
    https://www.cialismim.com/
    onde comprar cialis no rio de janeiro
    cialis 20 mg
    cialis bekommen
    cialis 20 mg

  36. Your comment is awaiting moderation.

    You actually reported it wonderfully!
    http://cialismsnntx.com/
    cialis las vegas nv
    generic cialis
    pret cialis romania
    buy cialis online

  37. Your comment is awaiting moderation.

    Thank you. Very good information!
    http://cialispego.com/
    onset of action of cialis
    cialis 20 mg
    cialis commercial male actors
    cialis 20 mg

  38. Your comment is awaiting moderation.

    You expressed this superbly.
    http://cialispego.com/
    quante ore prima assumere cialis
    buy cialis online
    efeitos colateral cialis
    buy cialis online

  39. Your comment is awaiting moderation.

    With thanks! I value it!
    https://www.cialisfidel.com/
    cialis Г© remedio controlado
    cialis without a doctor prescription
    effets du cialis 20mg
    cheap cialis

  40. Your comment is awaiting moderation.

    Appreciate it, Plenty of forum posts.

    http://cialismsnntx.com/
    glaucoma e cialis
    cialis generic
    cialis П„О№ОјО® О±ОіОїПЃО¬П‚
    cialis online

  41. Your comment is awaiting moderation.

    Cheers! An abundance of advice!

    http://cialispego.com/
    kein samenerguss cialis
    buy cialis online
    sono iperteso posso assumere cialis
    cialis online

  42. Your comment is awaiting moderation.

    Seriously loads of useful tips.
    https://www.cialisfidel.com/
    beneficios de la pastilla cialis
    generic cialis
    cialis eta’
    generic cialis

  43. Your comment is awaiting moderation.

    Reliable knowledge. Thanks a lot!
    http://cialismsnrx.com/
    cialis side effects kidneys
    cialis online
    quanto costa cialis in svizzera
    buy cialis online

  44. Your comment is awaiting moderation.

    You said it very well..
    http://cialispego.com/
    ready tabs cialis
    buy cialis online
    quando termina patente do cialis
    cialis generic

  45. Your comment is awaiting moderation.

    Cheers. I value it!
    http://cialismsnntx.com/
    cialis si sarcina
    cheap cialis
    cialis+avis des internautes
    cialis 20 mg

  46. Your comment is awaiting moderation.

    Nicely put, Appreciate it!
    http://cialismsnrx.com/
    cuanto tarda la cialis en hacer efecto
    cialis 20 mg
    when do you take cialis how often
    cialis without a doctor prescription

  47. Your comment is awaiting moderation.

    You said it perfectly..
    http://cialismsnntx.com/
    cura con cialis da 5 mg
    cialis online
    cialis 5 mg billig
    cialis 20mg

  48. Your comment is awaiting moderation.

    With thanks! Terrific information.
    http://cialisttk.com/
    can i take 10mg cialis daily
    cialis 20mg
    cheapest us cialis
    cheap cialis

  49. Your comment is awaiting moderation.

    You expressed this very well!
    http://cialismsnntx.com/
    data di scadenza del cialis
    cialis 20 mg
    medicina generica cialis
    cialis online

  50. Your comment is awaiting moderation.

    Valuable tips. Thank you!
    http://cialispego.com/
    123doc cialis
    cheap cialis
    lloyds pharmacy online cialis
    cialis generic

  51. Your comment is awaiting moderation.

    Thank you! I appreciate this.
    http://cialisttk.com/
    darf man cialis halbieren
    cialis online
    cialis side effects constipation
    cialis online

  52. Your comment is awaiting moderation.

    Regards. Awesome information.
    https://www.cialisfidel.com/
    enfermedad de peyronie y cialis
    cialis 20 mg
    how much is cialis daily use
    cialis online

  53. Your comment is awaiting moderation.

    With thanks. Great information!
    https://www.cialismim.com/
    cialis safe after stroke
    cialis 20 mg
    uso terapeutico cialis
    cialis 20mg

  54. Your comment is awaiting moderation.

    Truly all kinds of fantastic info!
    https://www.cialisfidel.com/
    esiste il generico del cialis in farmacia
    cialis online
    acheter cialis a lyon
    cialis 20mg

  55. Your comment is awaiting moderation.

    You said it adequately.!
    http://cialismsnntx.com/
    consiglio dove acquistare cialis
    cheap cialis
    side effects of mixing viagra and cialis
    cheap cialis

  56. Your comment is awaiting moderation.

    This is nicely said. .
    http://cialisttk.com/
    in welchem land ist cialis rezeptfrei
    cialis 20 mg
    quantos mg tem o cialis
    buy cialis online

  57. Your comment is awaiting moderation.

    You said it very well..
    http://cialispego.com/
    can you buy real cialis online
    cialis without a doctor prescription
    scatola cialis originale
    cheap cialis

  58. Your comment is awaiting moderation.

    Thank you, Useful stuff.
    https://www.cialisfidel.com/
    il cialis fa bene al cuore
    cheap cialis
    cialis in sperm
    cheap cialis

  59. Your comment is awaiting moderation.

    Amazing content. Many thanks.
    http://cialisttk.com/
    cialis sofort kaufen
    cialis 20mg
    cialis acheter en france
    cialis without a doctor prescription

  60. Your comment is awaiting moderation.

    Many thanks. Loads of posts!

    http://cialisttk.com/
    indications for cialis
    cialis 20mg
    che cosa serve il cialis
    cialis without a doctor prescription

  61. Your comment is awaiting moderation.

    This is nicely expressed. !
    http://cialismsnntx.com/
    cialis hind apteegis
    buy cialis online
    cialis prix pharmacie
    generic cialis

  62. Your comment is awaiting moderation.

    You made your stand pretty effectively!!
    http://cialispego.com/
    what should i expect when i take cialis
    cialis 20 mg
    cialis es de venta libre
    generic cialis

  63. Your comment is awaiting moderation.

    Beneficial advice. Appreciate it.
    https://www.cialisfidel.com/
    cialis 20mg comment utiliser
    cialis without a doctor prescription
    dosage for cialis 20mg
    cheap cialis

  64. Your comment is awaiting moderation.

    Really quite a lot of awesome information.
    https://www.cialismim.com/
    will alcohol effect cialis
    cialis without a doctor prescription
    price cialis 20mg
    cheap cialis

  65. Your comment is awaiting moderation.

    Terrific posts. Thanks a lot!
    https://www.cialisfidel.com/
    cancer prostate cialis
    cialis 20mg
    cialis consumer medicine information
    buy cialis online

  66. Your comment is awaiting moderation.

    Nicely put, Cheers!
    http://cialismsnrx.com/
    contraindicaciones de tomar cialis
    generic cialis
    cialis for daily use wiki
    generic cialis

  67. Your comment is awaiting moderation.

    Terrific forum posts. Thank you.
    http://cialismsnrx.com/
    cual es el mejor cialis levitra o viagra
    cialis 20mg
    whats best viagra cialis or levitra
    cialis 20 mg

  68. Your comment is awaiting moderation.

    You explained it well.
    http://cialismsnrx.com/
    cialis mercado libre chile
    cheap cialis
    harga obat cialis 80mg
    cialis without a doctor prescription

  69. Your comment is awaiting moderation.

    Regards. Wonderful stuff.
    http://cialisttk.com/
    cialis 2.5 mg preis
    cialis 20mg
    jual obat kuat cialis
    cialis 20mg

  70. Your comment is awaiting moderation.

    This is nicely expressed! !
    http://cialispego.com/
    medico di base prescrive cialis
    cialis 20 mg
    chinese name for cialis
    cialis online

  71. Your comment is awaiting moderation.

    With thanks. Excellent stuff!
    http://cialispego.com/
    lowest cialis price online
    cialis 20mg
    cialis precisa de prescrição medica
    cialis 20 mg

  72. Your comment is awaiting moderation.

    Nicely expressed really! .
    http://cialispego.com/
    buy cialis with a mastercard
    buy cialis online
    como se toma el cialis de 5mg
    cialis generic

  73. Your comment is awaiting moderation.

    Valuable info. Appreciate it.
    http://cialismsnntx.com/
    a quoi sert le medicament cialis
    generic cialis
    cialis con cortisone
    cialis 20mg

Leave a Reply

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