Using the below code to save the sessionID.
NSUserDefaults *sessions = [NSUserDefaults standardUserDefaults];
[sessions setObject:sID forKey:@"sessionsID"];
[sessions synchronize];
NSLog(@"Session Value Saved");
The code to retrieve the value is:
NSUserDefaults *sessions = [NSUserDefaults standardUserDefaults];
NSString *myString = [sessions stringForKey:@"sessionsID"];
NSLog(@"nsuser: %@", myString);
But on console it is showing like:
2012-01-03 15:37:37.292 LoginTest[574:12503] sID: c339af83caa5355d124f70e3f22c193d
2012-01-03 15:37:37.296 LoginTest[574:12503] Session Value Saved
2012-01-03 15:37:37.297 LoginTest[574:12503] Accounts: ("uid=demo@url.com", "o=Demo","o=Und")
2012-01-03 15:37:37.302 LoginTest[574:12503] sID: (null)
2012-01-03 15:37:37.304 LoginTest[574:12503] Session Value Saved
2012-01-03 15:37:37.304 LoginTest[574:12503] Accounts: (null)
2012-01-03 15:37:37.305 LoginTest[574:12503] No Session created
why is it being called two times and once it saves the values and shows them up and second time giving null.
I am using ARC.
I am messed-up with this… please guide me how can I resolve this issue
We dont know why it’s getting called twice; it’s your app 🙂
Put a breakpoint on
[sessions setObject:sID forKey:@"sessionsID"];The first time this gets hit
sIDwill be valid.Then something is happening that is invalidating
sID🙁The second time it gets hit it looks like
sIDisnull– you should be able to use the console / stack to work out why it’s being called twice.