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
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:
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.