doulieyu0881 2011-09-04 13:08
浏览 10

谁的在线脚本问题

Whilst creating a Who's Online script for my website, I've noticed that users of the same computer could of course have a different browser preference to other users.

What should happen in this situation?

I wish to find out the total number of users currently online, along with a breakdown of how many of these users are members or guests, and I need to find out how many users where online today, along with a breakdown of how many of these users are members or guests.

Any help is greatly appreciated.

  • 写回答

2条回答 默认 最新

  • dream3323 2011-09-04 13:26
    关注

    You can accomplish this using a sql database. Different browser settings do not make any difference, except for proxy.

    Every time someone opens your website, get their IP address and insert it into a table with this structure:

    (varchar)ip, (int)time
    

    Check if the ip is already in the database first and if that's the case, just update the time with current time.

    time();
    

    to get the number of online users just select from table where current time - time <= 300(online - has visited the site in the last 5 minutes). To check if it's a user, just check if the ip matches any accounts' ip address. If you don't store your members' ip addresses then it's about time to. Just update their ip address every time they login.

    To get the number of people who visited your website today select from that table where current time - time <= 86400 (24 hours)

    If you want the 'online today' counter to reset at midnight, create another column in the table storing the date(without time) the user visited the website, then simply check if it's today's date or delete all records every day.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答