unemployment Posted March 7, 2012 Share Posted March 7, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/258471-this-page-isnt-redirecting-properly/ Share on other sites More sharing options...
xyph Posted March 7, 2012 Share Posted March 7, 2012 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: Quote Link to comment https://forums.phpfreaks.com/topic/258471-this-page-isnt-redirecting-properly/#findComment-1324902 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.