Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count visited session using sessionStorage #58

Open
vinaysomawatshiprocket opened this issue Sep 12, 2024 · 0 comments
Open

Count visited session using sessionStorage #58

vinaysomawatshiprocket opened this issue Sep 12, 2024 · 0 comments

Comments

@vinaysomawatshiprocket
Copy link
Collaborator

vinaysomawatshiprocket commented Sep 12, 2024

  1. Start:

    • The system needs to track both the total number of visits and the number of unique visitors using total visit count and unique visit count stored in two separate text files.
  2. Step 1: Check LocalStorage for a visit flag:

    • If the visit flag exists in LocalStorage:
      • Proceed to Step 2.
    • If the visit flag does not exist in LocalStorage:
      • This is a unique visit. Increment both the total visit count and unique visit count by reading the current values from their respective files, updating them, and writing back the new counts to the files.
      • Set a visit flag in LocalStorage to indicate this unique visit.
      • Set a session flag in SessionStorage to track the current session visit.
  3. Step 2: Check SessionStorage for a session flag:

    • If the session flag exists in SessionStorage:
      • Do nothing (the user has already visited in this session).
    • If the session flag does not exist in SessionStorage:
      • This is a new session for the same user. Increment only the total visit count by reading the current value from the file, updating it, and writing back the new count.
      • Set a session flag in SessionStorage to indicate the session visit.
  4. End:

    • The system keeps track of both total visits and unique visitors without unnecessary updates, ensuring efficient session management.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant