title: FBConnect: session:didLogin never called starting from the second time the user tries to login?
body: <p>I am trying to use the FBConnect SDK to connect to Facebook. Everything works fine the first time the user tries to login: the delegate method <code>session:didLogin</code> gets called, then I am able to acquire the extended permission to update the user's status and to upload a picture.
  However, when the user taps the logout button, trying to connect again, starting from the second time on this always results in <code>session:didLogin</code> NEVER called. This occurs both when the session is cached (the user clicks on the checkbox in the FBLoginDialog) and when it is not.</p>
  
  <p>I just need to recognize correctly when the session is established in order to begin showing the button that the user needs to tap in order to acquire the extended permission.</p>
  
  <p>What is the correct/expected behavior among the following possibilities?</p>
  
  <p>1) if the session is cached then the second time the user logs in <code>session:didLogin</code> will not be called but the session is actually connected (i.e. <code>_session.IsConnected</code> must be <code>YES</code>) and nothing else needs to be done to establish the session;</p>
  
  <p>2) if the session is cached then the second time the user logs in <code>session:didLogin</code> will not be called and the session is not connected, so that further action is required to establish the session (what should I do in this case?);</p>
  
  <p>3) if the session is not cached, then the second time the user logs in <code>session:didLogin</code> will be called and the session is established; </p>
  
  <p>The relevant code follows. Please let me know if something is wrong and your current best practice to achieve multiple correct logins independently of the status of the session (cached or not). Thank you in advance.</p>
  
  <pre><code>- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
      if (self = [super initWithNibName:@"FacebookViewController" bundle:nibBundleOrNil]) {
  
          if (kGetSessionProxy) {
              _session = [[FBSession sessionForApplication:kApiKey getSessionProxy:kGetSessionProxy delegate:self] retain];
  
          } else {
              _session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain];
          }
      }
  
      return self;
  }
  
  
  - (void)viewDidAppear:(BOOL)animated {
  
      [super viewDidAppear:animated];
  
      BOOL resumed = [_session resume];
  
      _loginButton.style = FBLoginButtonStyleWide;
  
  
       if (_session.isConnected) {
           _permissionButton.hidden = NO;
       }
       else{
           _permissionButton.hidden = YES;
       }
  
      _statusButton.hidden = YES;
      _photoButton.hidden = YES;
  
  
      if(([_session isConnected] || resumed) &amp;&amp; self.name){
          _label.text = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Logged in as", nil), self.name];     
      }
      else{
          _label.text = [NSString stringWithFormat:@"%@", NSLocalizedString(@"You are not logged in", nil)];  
      }
  
  
  
  }
  
  
  
  - (void)session:(FBSession*)session didLogin:(FBUID)uid {
  
      NSLog(@"session:didLogin:");
  
      if(_session &amp;&amp; session != _session){
          [_session release], _session = nil;
      }
  
      if(!_session){
          _session = [session retain];
      }
  
      _label.text = @"";
      _permissionButton.hidden = YES;
      _statusButton.hidden     = YES;
      _photoButton.hidden      = YES;
  
      NSString* fql = [NSString stringWithFormat:@"select uid,name from user where uid == %lld", session.uid];
  
  
      NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"];
      [[FBRequest requestWithDelegate:self] call:@"facebook.fql.query" params:params];
  
  
  
  }
  
  
  - (void)dealloc {
  
      [_session.delegates removeObject: self];
      [_session release], _session = nil;
      [_permissionButton release], _permissionButton = nil;
      [_statusButton release], _statusButton = nil;
      [_photoButton release], _photoButton = nil;
      [name release], name = nil;
  
          [super dealloc];
  }
  </code></pre>