Solved

Facebook Php Logout

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

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 108

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
 

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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now