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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:27:16+00:00 2026-05-28T01:27:16+00:00

I am trying to make a like/unlike system, when a user clicks like on

  • 0

I am trying to make a like/unlike system, when a user clicks like on a post, his/her user id (which is stored in a session) and the post id will be stored in a database through an ajax call.

Then I thought what if some user make a html form with invisible input field (which has one of his post ids) on another domain and give its link to a user who checked remember me later or is viewing my site.

The user will click the button and The form will POST post id to my site, session contains user id and these will be stored in database.

No good solution comes to my mind. Is there any way more reliable than HTTP referrer to prevent this?

Thanks in advance

  • 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-05-28T01:27:16+00:00Added an answer on May 28, 2026 at 1:27 am

    One way is to insert a secret variable into the HTML which is specific to a user’s session. This can prevent cross site forgery.

    In PHP you’d generate a random ‘key’ and store it in the session:

    $_SESSION['myFormVar'] = md5(mt_rand());
    

    Then in a form, you’d add as a hidden variable:

    <input type="hidden" name="chkVar" value="<?=$_SESSION['myFormVar']?>"/>
    

    You should submit your form via POST and preferably over HTTPS, making it harder (but not impossible) to intercept the value of chkVar.

    In the code that processes your posted form, compare the posted chkVar against your session variable. In an ideal world, you’d have a unique chkVar per request, however using one which is the same for an entire session often works fine and guards against most csrf attacks.

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

Sidebar

Related Questions

Im trying to make something like this http://demos.99points.info/facebook_wallpost_system/ which is a comment system. I
I'm trying to make a new wx.Choice-like control (actually a replacement for wx.Choice) which
I'm trying to make like buttons on my site which basically submit a form
I am trying to make something like a Java style Enum, which I'm calling
I'm trying to make something like a spellchecker, that will list possible words under
I'm trying to make a Tetris-like game in XNA, and currently I'm thinking of
I'm trying to make a autoscrolling/carousel like function for an unordered list of images.
I am trying to make a chatroom layout like the following: Now my problem
I was trying to make a JMenu behave like a JButton but I'm having
I am currently trying to make a sectioned table like this: Section 1: Entry

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.