-1

I am trying to copy this online tool: https://www.joydeepdeb.com/tools/crawl-set-user-agent.html

Here is my code:

<?php
ini_set('user_agent', 'Testing/User-Agent');
?>

<iframe id="iframe" src="https://www.whatsmyua.info/" width="100%" height="100%"></iframe>

Instead of showing the fake user-agent ( Testing/User-Agent ), it shows my real browser's user-agent. How can I fix this? Thanks.

Ppap
  • 67
  • 7
  • There is no php code in the question emitting a http request (your browser loads the i frame). Given that, there’s no answer to the question as asked – AD7six Jan 15 '22 at 17:45
  • Does this answer your question? [Load iframe content with different user agent](https://stackoverflow.com/questions/12845445/load-iframe-content-with-different-user-agent) – Cristik Jan 20 '22 at 10:24

1 Answers1

0

IFRAME will always be opened with client's browser, so the UserAgent will be your actual UserAgent sent by your browser.

What you need to do is to open the URL from your PHP script (for example using fopen, or curl_exec), read a content, and return it to a client, instead of embedding in an IFRAME. Only then setting the UserAgent in the PHP script will work.

Just remember not to pass user input as a parameter for those functions to avoid introducing the Server Side Request Forgery vulnerability to your code.

Malipek
  • 196
  • 5