Solved

Facebook Php Logout

Posted on 2012-03-19
11
1,396 Views
Last Modified: 2012-04-02
I have this logout but it only logs out on facebook not on my site.

$logoutUrl=$_SESSION['logout'];

Open in new window

0
Comment
Question by:glynco
  • 6
  • 2
  • 2
  • +1
11 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 37737665
Eh?  Is there anything else you want to tell us?
0
 

Author Comment

by:glynco
ID: 37737821
I need a redirect to my logout.php after being log out on facebook.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 37737848
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:glynco
ID: 37738090
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

0
 

Author Comment

by:glynco
ID: 37738134
---------------------
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

0
 
LVL 8

Expert Comment

by:Ben McNelly
ID: 37738165
You can specify in your facebook app setting what you want the return URL to be.
0
 

Author Comment

by:glynco
ID: 37738409
Where is that? I cannot find it on settings
0
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 37740706
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>";
0
 

Author Comment

by:glynco
ID: 37740787
I need to log-out on both facebook website and on my site.
0
 
LVL 8

Accepted Solution

by:
Ben McNelly earned 500 total points
ID: 37742288
Ah, in that case I would make the link go to your logout page, that then redirects or has the facebook logout code in it.

Send user to your log out page
Log out page sends them to facebook log out
0
 

Author Comment

by:glynco
ID: 37745679
If I send them to my logout page first, how can I send them to facebook page if the session has already been destroyed?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question