-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Request: maintaining a session? #66
Comments
I think I have found the solution: Save the cookie session with login: [DIOSUser userLoginWithUsername:[NSString stringWithFormat:@"%@", username.text] andPassword:[NSString stringWithFormat:@"%@", password.text] success:^(AFHTTPRequestOperation *operation, id responseObject) {
#ifdef DEBUG When app loads send the session cookie in the Header: // Ir buscar os dados da última sessão através do NSUserDefaults.
#ifdef DEBUG Is this correct? -> [session setUser:responseObject]; or should it be [session setUser:[responseObject objectForKey:@"user"]];? |
You shouldnt have to sore the cookies at all, AFNetworking handles all of that and will resume the session until the cookies expire. |
@kylebrowning |
@m1n0 What do you mean? Basically you can store the user information returned from user Login by doing this. [session setUser:userDictInfo]; But you must keep in mind if you used responseObject it wont be retained properly. If you dont want to store that information thats okay, AFNetworking will keep the cookie until it expires. If you want to validate a user is logged in, you can use the system Resource and call 'connect' Does that help? |
Thanks, yes that is exactly what I need, I am just not sure if I know what you mean by "...you can use the system Resource and call 'connect'" |
https://github.com/workhabitinc/drupal-ios-sdk/blob/master/DIOSSystem.m You dont HAVE to do it with System, if you wanted you could use userLogin again and you should get a failure saying the user is already logged in. |
Ok, thanks a lot! |
How can I apply session to next ViewController after logging ? |
@paewrblue You should be able to just check the session - [DIOSSession sharedSession]. There is no need to check for the user. I too got confused. I think perhaps the documentation needs to be updated as based on the example in the documentation: I too thought the user is implicitly set to the session after logging whereas (from the above comments) I believe you will need to explicitly set the user to the session - [session setUser:userDictInfo];. This is most likely why you are probably nil when you just call [[DIOSSession sharedSession] user]; I hope it helps! |
How do I verify if a session is open in Drupal using the DIOS SDK? I don't find it in the documentation. I think that the documentation is also a bit outdated. Thank you.
The text was updated successfully, but these errors were encountered: