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 8031353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:04:43+00:00 2026-06-05T01:04:43+00:00

I have it set up to where I log each view in a table

  • 0

I have it set up to where I log each view in a table called question_views so each user can only be counted once.

However, I have a problem. Right now when you’re not logged in the view count just keeps incrementing because I don’t have a way to identify unregistered people (or people not logged in).

This is how I enter the users into the database for when they view:

function add_view($user, $question) {
  $ts = time();
  $check = mysql_num_rows(mysql_query("SELECT * FROM question_views WHERE user='$user' AND question_id=$question"));
    if($check==0) {
      mysql_query("UPDATE questions SET views=views+1 WHERE qid=$question");
      mysql_query("INSERT INTO question_views (user,question_id,date) VALUES ($user,$question,$ts)");
    }
}

When a user isn’t logged in, $_SESSION['userid'] (which is what is passed when the function is called) doesn’t even exist.

What would be a good way to make a view count system counting each viewer only once, including unregistered people?

EDIT: Of course there isn’t a way to do it reliably. But there is a way to do it at least somewhat good.

  • 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-06-05T01:04:45+00:00Added an answer on June 5, 2026 at 1:04 am

    Corbin’s got it right. Personally I’d use a cookie though. IP’s can be shared among several people, and sessions only last until you close your browser. I think a cookie’s your best bet, but of course, it can be deleted. Just set the lifetime to ‘forever’ or a long interval.

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

Sidebar

Related Questions

I have a history table where I log each request into a Web Handler
I have a table view and when a user selects a cell I want
I have a huge set of log lines and I need to parse each
I have set up a screen rc file like this: log on shelltitle apt
I have a SQLite database that contains a huge set of log messages. I
We have set the following app settings to be iPhone only, but in the
I'm maintaining an ASP.NET site where users can log on to register some set
I have my log file working, but I get extraneous info on each line
I have a list where each item is a row in an sqlite table,
I have a list where each item is a row in an sqlite table,

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.