Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Facebook Php Logout

Posted on 2012-03-19
11
Medium Priority
?
1,517 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +1
11 Comments
 
LVL 111

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 111

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
Technology Partners: 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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.
Suggested Courses

604 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