Finding total number of active sessions

前端 未结 5 1022
孤独总比滥情好
孤独总比滥情好 2020-12-18 10:28

I\'m a beginner to PHP and I\'m writing some code to my site. I want to get the total number of sessions that is active at that instant. I knew this is some difficult task b

5条回答
  •  眼角桃花
    2020-12-18 11:28

    If you add/have a mysql table for statistics analysis which has at least ip address and time columns, even if your site has no membership activity, table will be populated by clicks of visitors.

    In each of your page, insert ip and time to this table.

    Then you can fetch distinct ip addresses clicked at most 15 minutes ago. Duration is strictly related your content, it may be even 10 secs or 1 hour. Ask yourself if you were your visitor, how much will you surf on your site and be honest of course:)

    Lastly, your table will be fat after a time. Decide the frequency and logic and methodology to delete the useless rows. Clean the table on each arrival of your frequency which depends on your site traffic and sources.

提交回复
热议问题