Question:

PHP MYSQL counter logging double hits (not multiple...just two)?

by  |  earlier

0 LIKES UnLike

I created a table to insert a new record for each page visit. The code I have is pseudo like this: "If cookie is not set, then set the cookie and insert visitor information to the table".

The problem I have is about half of the truly unique visits to my page are inserting two identical rows into the DB. Even the same exact timestamp down to the second.

I tried echoing a debug statement inside the if statement to see if it was not setting the cookie. When I first visit the page, it shows my debug line "HIT!". Subsequent reloads and visits through the rest of the browser session do not show the debug line, so it seems to prove that it is only hitting the if statement once from the client perspective. Anyone have an idea how to resolve this?

 Tags:

   Report

2 ANSWERS


  1. It's difficult to debug the program when you don't have the actual codes.  Can you post the codes somewhere or at least provide a website with the codes?


  2. put a UNIK field on your table (use the time stamp + sessionID for example)

    then put a condition like:  if not exist (select * from table where unikField= theNewValue) Insert into table (new stuff)

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.