I have a table temp_views
which stores temporary views (for an hour) based on the ID of a post, the IP of the user and their user agent string.
SELECT COUNT(*) as viewed
FROM temp_views
WHERE showcase_id=:showcase_id AND ip=:ip AND user_agent=:user_agent
Both the IP and the user agent are stored in the table as simply TEXT
. (Should I be doing that another way?).
If viewed
is 0, then it adds a view - otherwise it does nothing.
What I'm wondering is, can this be "gamed" at all? If the IP matches but the user agent doesn't, then it will add a view. Can the user agent be spoofed easily or something? (A view is added asynchronously with Ajax as the user scrolls down the page).
Additionally, is this slow/inefficient or is it okay?