Link to home
Start Free TrialLog in
Avatar of glynco
glynco

asked on

Facebook Php Logout

I have this logout but it only logs out on facebook not on my site.

$logoutUrl=$_SESSION['logout'];

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Eh?  Is there anything else you want to tell us?
Avatar of glynco
glynco

ASKER

I need a redirect to my logout.php after being log out on facebook.
There are two ways you can redirect the client browser.  One is with the header() function.  The other is to put a meta-refresh tag into the browser output stream.  The latter method is "deprecated" however I have never encountered a browser that did not obey the command.

See these links for specifics:
http://php.net/manual/en/function.header.php
http://en.wikipedia.org/wiki/Meta_refresh
Avatar of glynco

ASKER

What I mean is I have to redirect after logging out on facebook.com

I tried this but it does not work

$facebook->getLogoutUrl( array(
    'redirect_uri'  => 'http://www.mydomain.com/fblogout.php')
);

Open in new window

Avatar of glynco

ASKER

---------------------
home.php

require 'facebook.php';
require 'fbconfig.php';
session_start();
$facebook=$_SESSION['facebook'];
$userdata=$_SESSION['userdata'];
$logoutUrl=$_SESSION['logout'];

//$logoutUrl = $facebook->getLogoutUrl(array('next' => $logoutUrl, 'session_key' => $session_key));


//$logoutUrl = $facebook->getLogoutUrl( array(
//    'redirect_uri'  => 'http://www2.mydomain.com/fblogout.php')
//);

Open in new window


-----------------
fbconfig.php

<?php
$facebook_appid='xxxxx';
$facebook_app_secret='xxxxx';
$facebook = new Facebook(array(
'appId' => $facebook_appid,
'secret' => $facebook_app_secret,
));
?>

Open in new window

You can specify in your facebook app setting what you want the return URL to be.
Avatar of glynco

ASKER

Where is that? I cannot find it on settings
Avatar of Loganathan Natarajan
instead of this,
$facebook->getLogoutUrl( array(
    'redirect_uri'  => 'http://www.mydomain.com/fblogout.php')
);

try,

echo "<script>window.location = 'http://www.mydomain.com/fblogout.php'</script>";
Avatar of glynco

ASKER

I need to log-out on both facebook website and on my site.
ASKER CERTIFIED SOLUTION
Avatar of Ben McNelly
Ben McNelly
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of glynco

ASKER

If I send them to my logout page first, how can I send them to facebook page if the session has already been destroyed?