Jump to content

This page isn't redirecting properly


unemployment

Recommended Posts

I am trying to integrate facebook login into my application.  If the user isn't logged in,  I want to make sure that they get sent to the index page, but this doesn't work.

 

<?php

if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
$user = null;
    //echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
  }
} else {
header('Location: /');
}

?>

 

Any thoughts on how to fix?

Link to comment
https://forums.phpfreaks.com/topic/258471-this-page-isnt-redirecting-properly/
Share on other sites

That's not a valid location.

 

Check the PHP manual on header. There's a note that states

 

HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.