title: Reliable check for active session on app startup in Facebook iOS SDK v4.0
body: <p>I am creating an iOS App with Facebook iOS SDK 4.0, using a simple Facebook login dialog with the <code>FBSDKLoginButton</code> view class. </p>
  
  <p>When starting the app after a previous successful login, the button correctly appears in "logged in" state, i.e. displaying the text "Log out".</p>
  
  <p>However, <code>[FBSDKAccessToken currentAccessToken]</code> is nil, which is why my App is unconscious of the active session and thus does not populate the FB-related fields with data.</p>
  
  <p>Since the <code>FBSession</code> class no longer exists with FB iOS SDK4.0, how can I correctly determine whether a cached session exists? </p>
  
  <p>I assumed that <code>[FBSDKAccessToken currentAccessToken]</code> was the way to do it. But, as mentioned, the <code>currentAccessToken</code> is not set... Any ideas why it could be nil, or how to correctly detect an active/cached session?</p>
  
  <p>EDIT: I have put the call to <code>currentAccessToken</code> in the <code>viewDidLoad</code> method of my main view controller, which contains the Facebook login dialog ad button. Unfortunately, the currentAccessToken is nil, as described above. Any suggestions why it is not available?</p>
  
  <p>EDIT2: Bigman solved the issue (see his comments in his answer below): Getting the <code>currentAccessToken</code> in <code>viewDidAppear</code> instead of <code>viewDidLoad</code> did the trick.</p>