This is the info on Facebook Login button
http://developers.facebook.com/docs/guides/web/
So it will render a Login button, and a user can click on it to log
FBML option: This should give you the functionality you want (with xfbml:true in FB.init):
<fb:login-button autologoutlink="true" onlogin="OnRequestPermission();">
</fb:login-button>
When the user is logged in, it changes to "Log Out." Also, if the user has not granted permissions to the app, it pops-up the request permission dialog.
Custom option: If you don't like using FBML, you can make your own Facebook login button like this:
HTML:
<button id="THE_BUTTON">Login</button>
Javascript:
FB.init({appId: 'YourAPPID', status: true, cookie: true, xfbml: true, oauth : true});
FB.getLoginStatus(function(response) {
if (response.status.toString().indexOf("connected")>-1) {
initAll(); //User is connected and granted permissions
FB.api("/me", function (response) {
document.getElementbyId("THE_BUTTON").value =
"Logged in as " + response.name;
});
} else {
// This URL is specially formed to ask permissions for your app. You change the
// permissions and your appID
//redirect_uri = Change this to your desired callback URL
top.location=window.location="http://www.facebook.com/dialog/oauth/?scope=read_stream,publish_stream,friends_photos,friends_activities&client_id="yourAPPID(nobrackets)"&redirect_uri=http://apps.facebook.com/filtered_feed/&response_type=code";
}
});
So if the user is logged in, the button will be replaced with "Logged in as user's name." Otherwise, the OAuth Dialog will appear.
1) You can also redirect on login using some code like this (note the auth.login event):
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId: '??????????????', cookie: true,
status: true, xfbml: true
});
FB.Event.subscribe('auth.login', function () {
window.location = "http://example.com";
});
</script>
<fb:login-button>
Login with Facebook
</fb:login-button>
2) To determine whether to show or hide the login button, you can use FB.getLoginStatus to discover whether the user is logged in. The following page might be of use: http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/