Skip to content

Instantly share code, notes, and snippets.

@mitchellh
Created October 27, 2009 08:14
Show Gist options
  • Save mitchellh/219409 to your computer and use it in GitHub Desktop.
Save mitchellh/219409 to your computer and use it in GitHub Desktop.
FB.Event.subscribe('auth.sessionChange', function(response) {
// The cookies we need to set for Facebooker, and the
// associated key into the Mu session object
var cookies = {
session_key: 'session_key',
user: 'uid',
expires: 'expires',
ss: 'secret'
};
// If the session is not set, expire the cookies
var timestamp = response.session ? response.session.expires : 0;
// Set the Facebooker cookies. These cookies must be set
// with the format: APIKEY_NAME where NAME is one of the
// keys of the above cookies hash.
for (var cookie_name in cookies) {
var session_key = keys[cookie_name];
var val = response.session ? response.session[session_key] : '';
document.cookie =
FB._apiKey + '_' + cookie_name + '=' + val +
'; expires=' + new Date(timestamp * 1000).toGMTString() +
'; path=/';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment