I have an application which uses wcf web service and after successful login, i want to activate a session of 10 minutes. If user is idle or app is in background for 10 minutes then session should expire and app should ask for login details again.
I have used keychain for storing username and password and it works But i want to add the session so that user is redirected to main page if session is not expired and to the login page if session is expired...
I know this is repeated question but i had to write it since i am not getting proper answer from other questions. Please help..
Sessions track a common pattern, in which a given user opens an app and interacts with it for a period of time, then moves on to another app, or stops using their device. Various Output partners use sessions to group user interactions. All events tracked during a session will also share a Session ID.
A session is a period of time wherein a user interacts with an app. Usually triggered by the opening of an app, a session records the length and frequency of app use to show developers, marketers and product managers how much time users spend within an app.
To exit a session on an iPhone, tap the Actions button, and then tap the End or Hold Session button at the bottom of the menu. If you are the session owner, End Session closes the session page in your representative console and removes any additional representatives who may be sharing the session.
use this Link this works me.
use NSUserDefault to create Session for ios.
i also created Session in ios with this Tutorial.
EDIT:
i have a Login Screen in first Page of My application
if Login is Successfull authenticate by server then i stored my Username & Password in NSUserDefault Like this way:
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:userNameText forKey:@"username"];
[defaults setObject:passWordText forKey:@"password"];
[defaults synchronize];
Onclick of Login Button. & redirected to Dashboard.
In dashboard Logout Button is there if user click Logout Delete All Data Like this way.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults removeObjectForKey:@"username"];
[defaults removeObjectForKey:@"password"];
[defaults synchronize];
& On other condition when user close app The NSUSerDefault Are stored when u second time open app at that time Check wheather username & password stored in NSUserDefault
During ViewDidAppear
of Loginpage.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// check if user is alraidy Login
if([defaults objectForKey:@"username"]!=nil && ![[defaults objectForKey:@"username"] isEqualToString:@""]){
// Redirected to Dashboard.
}
If sucessfull then Redirected to Dashboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With