Skip to content

Instantly share code, notes, and snippets.

@prabirshrestha
Created November 23, 2010 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prabirshrestha/711352 to your computer and use it in GitHub Desktop.
Save prabirshrestha/711352 to your computer and use it in GitHub Desktop.
Logout of Facebook website using FacebookJsSdk
<%@ Page Language="C#" %>
<%@ Import Namespace="FacebookSharp.Web.JavascriptSdk" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Logging you out of facebook...</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Logging you out of Facebook...</p>
<div id="fb-root">
</div>
<script src="<%= FacebookJavscriptSdk.GetFacebookJsSdkUrl("en-US",false) %>" type="text/javascript"></script>
<script type="text/javascript">
<%= FacebookJs.Init() %>
FB.getLoginStatus(handleSessionResponse);
// handle a session response from any of the auth related calls
function handleSessionResponse(response) {
// if we dont have a session (which means the user has been logged out, redirect the user)
if (!response.session) {
window.location = "<%= FacebookContext.Settings.FacebookAuthorizeUrl %>";
return;
}
// if we do have a non-null response.session, call FB.logout(),
// the JS method will log the user out
// of Facebook and remove any authorization cookies
<%= FacebookJs.Logout("handleSessionResponse") %>
}
</script>
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment