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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:33:25+00:00 2026-06-12T19:33:25+00:00

Description: I am creating comment/reply functionality to a web app that I built. I

  • 0

Description:

I am creating comment/reply functionality to a web app that I built. I have a post that I want to link these comments too. To decrease spam and encourage community involvement I want to implement a voting system on each comment/reply.

Problem:

I know how to set up the database and I know how to show upvotes/downvotes. The only thing I don’t know what to do is to keep the vote… voted even if the user refreshes the page. I don’t want a user to be able to vote up more than once on a single post. Something like the voting on this site, it tracks that you have already voted with a yellow upvote.

What I have thought of:

  • Place post id in cookie with the user_id appended to it. A simple check of the cookie can stop the user from voting again
  • Place a unique constraint in table post id… but this is where I get confused. Should I have a separate table just for voted posts? Database schema idea ( I think ) here: https://stackoverflow.com/a/12350981/185672
  • Keep all the ids in a session array and check against all voted on ids… but that would get huge.
  • Combination of cookie and database to reduce number of db calls.

In the future there may be 1000s of votes cast by a single user.

edit:

I figured out that storing the results in a database is a must. How can I check for every reply/comment if the user has valid voting privileges without making 1000s of calls?

Resources:

Helped with some further spamming problems, but didn’t answer initial question:
https://stackoverflow.com/a/2333085/185672

Old solution that explains how to count votes but not keep the “upvote” checked.
http://www.9lessons.info/2009/08/vote-with-jquery-ajax-and-php.html

Bonus question:

If you guys know of a great script that can allow me to sync up a commenting system ( with votes ) into my already built app?

Also, I tried to find duplicates, but I just can’t.

  • 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-12T19:33:26+00:00Added an answer on June 12, 2026 at 7:33 pm

    Yeah, just keep a separate table to track user votes. Since you know which user is requesting the page, you can easily join the votes table to determine the current user’s eligibility to vote on each post on the page. For each post, if they’re eligible, output one version of html, if they’re not then output another.

    Once the ajax request asks for the php file that does the vote, you can then check once more that that user is eligible to vote – I.e they’re changing their vote, or they haven’t voted before.

    Take yahoo’s news stories for example – when you request a page that you’ve made a comment on, your own comment has disabled voting buttons. With some hacking of the page inside the browser’s dev tools, you can enable the buttons. You can even click on them and vote for your own post – though only once.

    So, you can see that they got 2/3rds of it right, and output html based on the user’s eligibility to vote. They also prevent multiple voting (server-side), they just don’t do a server-side check to ensure you’re not voting for your own comment.

    Stack Overflow on the other hand, always shows the same html – but when you click to vote for your own comment, the server-side code baulks at the idea and the response is basically ‘bugger-off! you can’t do that’ having received a negative result from the server, the javascript on the page pops up the message, rather than updating the vote count.

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

Sidebar

Related Questions

i'm creating a map app that displays events with a description overlay that pops
I have a form for creating materials (title, description and content - all basic).
How do I create a custom description and image when im creating a share-link
I am creating description label in which i want my description label height should
Description of the problem: I'm creating a scrollable list of articles with thumbnails that's
I am creating an online system that matches bank statements (description, value, type, etc)
I'm creating a list of divs that I want to slide. Each slide has
Description : I am creating customized title bar. The codes for customization is as
Description: An unhandled exception occurred during the execution of the current web request. Please
Description: I have a problem regarding DataGridView . I need to show a Client_Name

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.