How to do a logout

16 views
Skip to first unread message

matte

unread,
Nov 12, 2009, 10:28:32 AM11/12/09
to ObjectiveResource
Hi there, I'm a Rails developer and now I started developing iPhone
app... Almost everything is fine with ObjectiveResource, but I have a
question (I read all the groups and documentation and I couldn't find
a solution).

Once you set username and password from iPhone you get a session
object and you can access your rails app data. But how can I change
username and password in the iPhone app to access data for another
user? The session seems to persist even if I reset
ObjectiveResourceConfig with new credentials:

[ObjectiveResourceConfig setUser:@"new_username"];
[ObjectiveResourceConfig setPassword:@"new_password"];

Thanks in advance
Matteo

mratliff

unread,
Dec 4, 2009, 1:21:55 PM12/4/09
to ObjectiveResource
Did anyone find a solution to this problem?

pcrawfor

unread,
Dec 4, 2009, 1:45:58 PM12/4/09
to ObjectiveResource
Hey guys,

I ran into this behavior where the session was hanging around - it
turns out that the way to get past it is change a setting on the
request object.

[request setHTTPShouldHandleCookies:NO];

I modified + (Response *)sendRequest:(NSMutableURLRequest *)request
withUser:(NSString *)user andPassword:(NSString *)password
to change this setting on the request before the connection object is
created.

Paul

Anurag

unread,
Dec 9, 2009, 11:58:57 PM12/9/09
to ObjectiveResource
I use a different approach to remove the current session from iPhone -
I send a request to the "destroy" action of session_controller which
destroys the existing session (as it contains some code like: session
[:user_id] = nil, cookies[:auth_token] = nil, etc. )

Then call these two lines:
[ObjectiveResourceConfig setUser:nil];
[ObjectiveResourceConfig setPassword:nil];

This approach works for me. Hope it helps others too.

comonitos

unread,
Oct 22, 2012, 3:45:03 AM10/22/12
to objectiv...@googlegroups.com

faced the same problem. You all need to perform this:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

        

        NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];

        for (NSHTTPCookie *c  in cookies) {

            [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:c];

Reply all
Reply to author
Forward
0 new messages