Change User-Agent Using PHP

12,381
ini_set('user_agent', 'MyBrowser v42.0.4711');
Share:
12,381
AbdulFattah Popoola
Author by

AbdulFattah Popoola

Relentless learner, JS and CS linkedin

Updated on June 04, 2022

Comments

  • AbdulFattah Popoola
    AbdulFattah Popoola almost 2 years

    I have an app on my server which redirects to Facebook and thus displays the browser version of the Facebook Login page.

    However, since I'll be accessing this through a mobile device, I'll want it to display the mobile version of the Facebook login page.

    Is it possible to use the header() function or is there a way to change the user-agent on my host before it redirects to Facebook? So that Facebook will think the request is coming from a mobile device and thus render the mobile version.

    I have already tried to use JavaScript and tried spoofing the header command; unfortunately these didn't work.

    Thank you.

  • ZJR
    ZJR almost 2 years
    this is THE answer