Search code examples
jqueryasp.netcookiesvoting

Saving cookies for voting ASP.NET


My problem is simple yet I couldn't find the best solution to it.

I want to know if someone voted on a post ON PAGE LOAD (not when they vote) and if they did, change the voting image so that they can see they already voted on it.

Best solution that came to my mind was to save cookies, first question is "is it good practice to save cookies and loop through all posts to find if cookie exists?"

second question is: if it is a good solution, what should be the way to save cookies? Since only registered members will be able to vote, keeping username and postId should be enough.. or not?

Thank you


Solution

  • Depending on the browser, cookies have a size limit so this may not be the best approach.

    You mention that you are keeping the votes in the DB. When the page is requested just look at that table and send the appropriate image down.