PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, March 6, 2022

[FIXED] Facebook Login integration using PHP SDK 4.0 - HTTP_REFERER missing on redirect

 March 06, 2022     facebook, facebook-php-sdk, php     No comments   

Issue

I was trying to integrate Facebook Login using PHP SDK 4.0. Everything is going good except HTTP_REFERER is missing in the page redirected by Facebook after successfull login (User authorizes the app and grants requested permission.)

Login page:

<?php
...
$loginHelper = new FacebookRedirectLoginHelper('localhost/login/facebook/verify.php');
$loginURL = $loginHelper->getLoginUrl();
header("Location: $loginURL");
...
?>

verify.php page:

<?php
if (isset($_SERVER['HTTP_REFERER'])) {
    if (strpos($_SERVER['HTTP_REFERER'], 'facebook.com') !== false) {
        // Redirected from Facebook
       ...
    }
}
?>

The php.net documentation states :

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

So, is it really Facebook not setting this particular header or I'm doing it wrong somewhere?


Solution

It is your web browser that should set the HTTP_REFERER header not Facebook itself. When your site is being linked or redirected from a HTTPS site, the browser will not set a referrer.



Answered By - WizKid
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing