Solved

Facebook Php Logout

Posted on 2012-03-19
11
1,379 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 109

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 109

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
PHP strings vs array errors 13 32
Add email address from a web page to outlook 2010 contacts ? 8 40
Custom Wordpress Loop 22 38
Uploading a CSV Data Import via PHP & MySql 3 29
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

792 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