title: Global variable value issue iPhone
body: <p>I have declared a variable  NSString sessionId; in app delegate file for global usage. </p>
  
  <p>In appdelegate.h</p>
  
  <pre><code>@property (strong, nonatomic) NSMutableString *sessionId;
  </code></pre>
  
  <p>In appdelegate.m</p>
  
  <pre><code>@synthesize sessionId;
  </code></pre>
  
  <p>And used it in one of my view controller like this.</p>
  
  <pre><code>    ((VektorAppDelegate *)[UIApplication sharedApplication].delegate).sessionId = sID.retain;
  
  NSLog(@"session id = %@", ((VektorAppDelegate *)[UIApplication sharedApplication].delegate).sessionId);
  </code></pre>
  
  <p>I am able to accèss that variable sessionId in all of my view controllers but the issue is that the value is not getting saved in it. Like in viewcontroller1.m, I assigned it some value but when I accessed sessionId in another viewcontroller2.m, its showing its value as null on console.</p>
  
  <p>How can I resolve this issue.</p>
  
  <p>Code added:</p>
  
  <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
       NSString *responseString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
  
  self.receivedData = nil;
  
  
      NSError *error;
  
      SBJSON *json = [[SBJSON new] autorelease];
  
      NSArray *session = [json objectWithString:responseString error:&amp;error];
  
      SBJsonParser *parser =[[SBJsonParser alloc] init];
  
      NSDictionary *jsonObject = [parser objectWithString:responseString];
  
      sID = [jsonObject objectForKey:@"session"];
  
      ((VektorAppDelegate *)[UIApplication sharedApplication].delegate).sessionId = sID;
  
      NSLog(@"session id = %@", ((VektorAppDelegate *)[UIApplication sharedApplication].delegate).sessionId);
  
  
      NSUserDefaults *sessID = [NSUserDefaults standardUserDefaults];
  
      [sessID setObject:sID forKey:@"sessionID"];
  
      [sessID synchronize];
  
      NSLog(@"This session %@ saved", sID);
  
      NSDictionary *accountsObj = [parser objectWithString:responseString];
  
      NSString *accounts = [accountsObj objectForKey:@"account"];
  
      NSArray *accountList = [accounts componentsSeparatedByString:@","];
  
      NSLog(@"Accounts: %@", accountList);
  
  
      if (session == nil)
      NSLog(@"JSON parsing failed: %@", [error localizedDescription]);
  else {
  
      if (accountList.count &gt; 1) {
  
          ChooseAccountsController *accountsView = [[ChooseAccountsController alloc] initWithNibName:@"ChooseAccountsController" bundle:nil ];
  
          self.chooseAcc = accountsView;
  
          [self.view addSubview: accountsView.view];
      } else if (accountList.count == 1) {
  
              MainScreenController *mainScreen1 = [[MainScreenController alloc] initWithNibName:@"MainScreen" bundle:nil ];
  
               self.mainScreen = mainScreen1;
  
               [self.view addSubview: mainScreen1.view];
  
           }
      }
  
  }
  </code></pre>