Search Results

Search found 7 results on 1 pages for 'nshttpcookie'.

Page 1/1 | 1 

  • iPhone: NSHTTPCookie is not saved across app restarts

    - by Tom van Zummeren
    In my iPhone app, I want to be able to reuse the same server-side session when my app restarts. A session on the server is identified by a cookie, which is sent on each request. When I restart the app, that cookie is gone and I can't use the same session anymore. What I noticed when I used the NSHTTPCookieStorage to look up the cookie I got from the server, is that [cookie isSessionOnly] returns YES. I get the impression that this is why cookies are not saved across restarts of my app. What would I have to do to make my cookie NOT session only? What HTTP headers do I have to send from the server?

    Read the article

  • Google Reader API with Objective-C - Problem getting token

    - by JustinXXVII
    I am able to successfully get the SID (SessionID) for my Google Reader account. In order to obtain the feed and do other operations inside Google Reader, you have to obtain an authorization token. I'm having trouble doing this. Can someone shed some light? //Create a cookie to append to the GET request NSDictionary *cookieDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"SID",@"NSHTTPCookieName",self.sessionID,@"NSHTTPCookieValue",@".google.com",@"NSHTTPCookieDomain",@"/",@"NSHTTPCookiePath",@"NSHTTPCookieExpires",@"160000000000",nil]; NSHTTPCookie *authCookie = [NSHTTPCookie cookieWithProperties:cookieDictionary]; //The URL to obtain the Token from NSURL *tokenURL = [NSURL URLWithString:@"http://www.google.com/reader/api/0/token"]; NSMutableURLRequest *tokenRequest = [NSMutableURLRequest requestWithURL:tokenURL]; //Not sure if this is right: add cookie to array, extract the headers from the cookie inside the array...? [tokenRequest setAllHTTPHeaderFields:[NSHTTPCookie requestHeaderFieldsWithCookies:[NSArray arrayWithObjects:authCookie,nil]]]; //This gives me an Error 403 Forbidden in the didReceiveResponse of the delegate [NSURLConnection connectionWithRequest:tokenRequest delegate:self]; I get a 403 Forbidden error as the response from Google. I'm probably not doing it right. I set the dictionary values according to the documentation for NSHTTPCookie.

    Read the article

  • Get objc_exception_throw when setting cookie with ASIHTTPRequest

    - by TuanCM
    I got objc_exception_throw when trying to set cookies for a ASIHTTPRequest request. I tried both of these but it didn't work out. ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:url]; NSMutableDictionary *properties = [[NSMutableDictionary alloc] init]; [properties setValue:@".google.com" forKey:@"Domain"]; [properties setValue:@"/" forKey:@"path"]; [properties setValue:@"1600000000" forKey:@"expires"]; NSHTTPCookie *cookie = [[NSHTTPCookie alloc] initWithProperties:properties]; [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; or replacing initiating code for cookie with this one NSHTTPCookie *cookie = [[NSHTTPCookie alloc] init]; When I commented out the following line, everything worked fine. [request setRequestCookies:[NSMutableArray arrayWithObject:cookie]]; Can you guys tell me what the problem here!

    Read the article

  • I can create a cookie, but can't delete it from my iPhone app

    - by squeezemylime
    I am creating an iPhone app, and am using this method to create a cookie that will be accessed site-wide: NSMutableDictionary *cookieDictionary = [NSMutableDictionary dictionaryWithCapacity:4]; [cookieDictionary setObject:@"status" forKey:NSHTTPCookieName]; [cookieDictionary setObject:[self.usernameField text] forKey:NSHTTPCookieValue]; [cookieDictionary setObject:@"http://www.mydomain.com" forKey:NSHTTPCookieDomain]; [cookieDictionary setObject:@"/" forKey:NSHTTPCookiePath]; // Build the cookie. NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieDictionary]; // Store the cookie. [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie]; // Log the Cookie and display it for (cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) { NSLog(@"%@", cookie.value); } Now I am trying to delete it via the following method, but it isn't working, and the documentation isn't quite helping me: NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; NSArray* theCookies = [cookieStorage cookiesForURL:[NSURL URLWithString:@"http://mydomain.com"]]; for (NSHTTPCookie *cookie in theCookies) { [cookieStorage deleteCookie:cookie]; }

    Read the article

  • How do I check the value of a cooke in other places in my iPhone app?

    - by squeezemylime
    I am setting a cookie to whether a user is logged in or not in my iPhone app. I set it using the following: // Build the cookie. NSHTTPCookie *cookie = [NSHTTPCookie cookieWithProperties:cookieDictionary]; // Store the cookie. [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie]; // Log the Cookie and display it for (cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) { NSLog(@"%@", cookie.value); } However, if I run this loop in other parts of the app (the 'for' loop), it isn't recognized...Is there a simple way I can find the value in other views of the app?

    Read the article

  • Cant access NString after callback in [NSURLConnection sendSynchronousRequest]

    - by John ClearZ
    Hi I am trying to get a cookie from a site which I can do no problem. The problem arises when I try and save the cookie to a NSString in a holder class or anywhere else for that matter and try and access it outside the delegate method where it is first created. - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { int i; NSString* c; NSArray* all = [NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:[NSURL URLWithString:@"http://johncleary.net"]]; //NSLog(@"RESPONSE HEADERS: \n%@", [response allHeaderFields]); for (i=0;i<[all count];i++) { NSHTTPCookie* cc = [all objectAtIndex: i]; c = [NSString stringWithFormat: @"%@=%@", [cc name], [cc value]]; [Cookie setCookie: c]; NSLog([Cookie cookie]) // Prints the cookie fine. } [receivedData setLength:0]; } I can see and print the cookie when I am in the method but I cant when trying to access it form anywhere else even though it gets stored in the holder class @interface Cookie : NSObject { NSString* cookie; } + (NSString*) cookie; + (void) setCookie: (NSString*) cookieValue; @end int main (void) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; JCLogin* login; login = [JCLogin new]; [login DoLogin]; NSLog([Cookie cookie]); // Crashes the program [pool drain]; return 0; }

    Read the article

  • iPad App Cookies Storage?

    - by Aakburns
    Hi, I have an application that sends you to one website that shows a login form. I've read up on cookies from the apple reference (http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookie_Class/Reference/Reference.html#//apple_ref/occ/instm/NSHTTPCookie/initWithProperties:) I'm honestly just not understanding this at all. Can someone please explain how to get cookies working for an app? Post sample code? Thanks.

    Read the article

1