mitchellh (owner)

Revisions

gist: 219409 Download_button fork
public
Public Clone URL: git://gist.github.com/219409.git
Embed All Files: show embed
Mu + Facebooker #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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=/';
  }
});