Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question about date and time

    Hi all. i'm new so bare with me. I visit many forums and I always get off to
    a slow start.
    My question is this: Is it possible to collect the date and time from a user
    visiting my website, store it, then get the amount of time the user has spent
    on my site using javascript? Thanks in advance. If this is in the wrong place
    please let me know.

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Kinda sorta.
    But not with pure javascript (it has to store it somewhere on your site, such as DB or sessions to be of any use, so you need server-side scripting, too) and not 100% accurate. Users can disable script.

    Your best bet, if you're looking for site stats, are the ones provided by your host. Many hosts have more than decent stats. One of mine tells me what page they came in on, what page they left on, and how long they stayed (if it can guess based on the previos data) on each page. Reports on most used pages, how many times served in a given timeframe, and more.

    As always nothing is 100%, but they're pretty decent for accuracy. The server itself logs IPs, sessions, and such.

    You just can't duplicate that stuff with javascript. If you really care, go host hunting.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the reply. Ya, I kinda thought that I'd have to use something like asp or aspx to get the job done. Thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •