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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:04:35+00:00 2026-06-14T04:04:35+00:00

There is a way to inject code via ajax or to fake information? Like

  • 0

There is a way to inject code via ajax or to fake information?

Like to send Ajax from my website to another website that use ajax?

If so how can I prevent this that I can send ajax only from my website?

  • 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-14T04:04:36+00:00Added an answer on June 14, 2026 at 4:04 am

    You’re probably looking for CSRF (cross-site request forgery) protection. The issue is that your site has no idea where AJAX requests are coming from. The generally accepted solution is to create a token that is sent from your site which is required to be sent along with AJAX requests.

    This token would be unique to a user session and output somewhere in the HTML of your page. This makes it challenging for other sites to capture this token.

    To give you the basic idea, you would do something like this:

    $_SESSION['csrf_token'] = md5(uniqid(rand(), TRUE));
    

    Then you could for example output this as a JavaScript variable

    <script>
    window.CSRF_TOKEN = '<?php echo $_SESSION['csrf_token']; ?>';
    </script>
    

    If you happen to be using jQuery, you can use ajaxSend() to add the token to each request

    $.ajaxSend(e, jqXHR, settings) {
      if (!settings.data) settings.data = {};
      settings.data['csrf_token'] = window.CSRF_TOKEN;
    }
    

    Finally, on the backend you would check that $_REQUEST['csrf_token'] ==$_SESSION[‘csrf_token’]` to validate the request. It’s generally a good idea for these tokens to be one-time use if possible. Storing the time the token was generated and making sure it’s used within a reasonable time frame is also a good idea.

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

Sidebar

Related Questions

Is there a way to detect via JavaScript (client side) any AJAX requests that
Is there a way to inject R code output into the generated document without
is there way how to get name ov event from Lambda expression like with
is there a way to inject arbitrary code into a jar file? for example,
Is there a way to have a partial class' constructor call another method that
With Javassist, is there any way to inject code into a native method? In
Is there a way to inject EJB 3 stateless session beans into struts 2
Is there any way we can inject new methods and properties into classes during
Is there way to get file from windows xp command prompt? I tried to
I have a WPF UserControl that I'd like to inject dependencies into. What's the

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.