May 17, 2025

2 thoughts on “PHP Sessions: Count Number of Site Visits

  1. Thanks for you article. I am the administrator of ridplace.com. And i would like to display the number of active sessions. My problem/question: when do we call the unset ou destroy (or -1) session? we don’t know when the user is out….

    1. Hi. It depends on what you are trying to achieve. session_destroy() removes all active sessions for a user, while unset($_SESSION[“value”]) deletes a particular session that has previously been set. If you are authenticating users or they are logging in any form, you can destroy the session when they logout using session_destroy(). If you still want to track activities, you can unset the session.

Leave a Reply

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