Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7195739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:38:20+00:00 2026-05-28T20:38:20+00:00

For a web application I’m writing it’s going to be key to measure at

  • 0

For a web application I’m writing it’s going to be key to measure at a frequent interval (every minute or so) how many visitors are in a specific part of my application right now. Say my application has 10 subsections that are switched between using JavaScript and made persistent using #!/page8 style hash anchors. What would be the best way of doing this accurately?

My current plan is to just save the amount in a database, adding and subtracting every time a user clicks on the page or leaves the page. This doesn’t really seem like a very good solution to me though. Events to track page leaves could be cancelled due to closing browsers, people could be screwing with the data by running the API calls for visiting/leaving etc. It would be a lot of work to get reliable.

Edit: To specify, my application won’t have user accounts. Also I’m not just trying to log how many visitors my pages have had. I’m trying to accurately know how many visitors are on my page right now. Which means that I’ll need some reliable method of knowing then a visitor is no longer on my page. That’s where the problem lies. I just got a bright idea that I could have the JavaScript on their page notify my server every 10 seconds or so that they are still there, and have their visit be timed out and removed if they don’t. Would that work? Couldn’t this be a problem for my puny server if I were to get thousands of people using my app simultaneously?

Any thoughts?


I’m tagging this with a lot of common web development tags since it’s a very open question and any of these tags could contain the answer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:38:21+00:00Added an answer on May 28, 2026 at 8:38 pm

    Depending on the server capacity you have you could employ recurring requests to a .php file that would keep a custom session track alive. But beware – this causes wast load on the server, so only go this way if you are aware of the consequences!

    With session_start(); you could write a custom session identifier in a database table with fields like ID, ip_addr, session_track_id, timestamp. Don’t use the session_id itself as that might be a security issue. Update the timestamp in each .php you call.

    Additionally create a custom .php where only the timestamp is updated. Call this via jQuery AJAX calls every 60 seconds (or whatever interval you need). You could employ some security to this step too to avoid direct API call you mentioned. For example issue a next request id that is returned in the AJAX calls and needs to be a parameter of the next one, if it’s not, the timestamp won’t be updated.

    Create a cron that runs every 90 seconds (or whatever interval you need – but longer than in the AJAX calls obviously). This cron would look for entries in the table that are older than X seconds and delete them.

    To find out the number of active users simply count the rows in the table.

    There are additional security options that could be employed in this approach.

    This would solve your situation – when a user would close his window, no AJAX calls would keed the session alive anymore and it would get deleted from the database after some seconds (90 in the scenario above).

    However – consider that when you issue a request every 60 seconds and you have 1000 users online, it’s at least 60 000 requests per hour to you database! Strong optimalization is a must here…

    This solution worked fine for me in one project however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A web application we wrote intended for one customer is going to be product-ized
Our web application needs one common parameter in every action method. In our case
My web application generates pdf files and either e-mails or faxes them to our
My web application has a login page that submits authentication credentials via an AJAX
My web application sends email fairly often, and it sends 3 kinds of emails:
Our web application renders fast in some IE browsers, slow in others... It seems
Our web application sends e-mails. We have lots of users, and we get lots
My web application (MonoRail, Windsor, ActiveRecord) has a Startable import service and one or
My web application worked very well in a Windows Server 2003 with .NET Framework
My web application crashes almost once a week due to not enought memory error.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.