5

Having a few issues with my current build of PandoraMan (http://github.com/zquestz/PandoraMan). Everything is functional for the most part, window position is being saved, all essential functionality works, however I am seeing one bug.

When I login to Pandora, it never gets preserved. I was under the assumption that it read the system cookies and shared state with Safari. The older version (using an ancient xcode on 10.4) worked fine.

If I launch the app and login using PandoraMan, it logs in, and the site works as normal. However when I restart the app I always have to login again. This never used to happen, and I can't find anything in the docs regarding this issue.

If anyone has some insight on this issue it would be fantastic. The code is open source, so you can check out the issue without bouncing code back and forth in the comments.

quest
  • 776
  • 5
  • 14
  • I tried a few other sites, for everything other than Pandora I am able to maintain my login... this gets more and more bizarre. – quest Nov 23 '11 at 23:20
  • Any update to this? I'm also having this issue creating a my own stand alone pandora app. Have you confirmed this is a Pandora specific issue ? – ndmweb Nov 16 '12 at 23:21
  • was there any solution to this? – Pedro Estrada Jun 03 '13 at 17:06

2 Answers2

1

Pandora uses localStorage to preserve user state. Use this:

WebPreferences* prefs = [WebPreferences standardPreferences];
[prefs _setLocalStorageDatabasePath:@"~/Library/Application Support/MyApp"];
[prefs setLocalStorageEnabled:YES];
[self.webView setPreferences:prefs];

Add these to the beginning of the file:

@interface WebPreferences (WebPreferencesPrivate)
- (void)_setLocalStorageDatabasePath:(NSString *)path;
- (void)setLocalStorageEnabled:(BOOL)localStorageEnabled;
@end

More: How do I enable Local Storage in my WebKit-based application?

Community
  • 1
  • 1
Vojto
  • 6,901
  • 4
  • 27
  • 33
1

Your application has its own "cookie jar" in the [NSHTTPCookieStorage sharedHTTPCookieStorage] container.

Here's how you might take a quick look at the cookies in your application's cookie jar:

NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
    NSLog(@"%@", cookie);
}

Several methods are available for filtering and manipulation. Take a look at the NSHTTPCookieStorage documentation for accessing cookies, and the NSHTTPCookie documentation for accessing individual cookie properties

May be this can help your problem.

Monolo
  • 18,205
  • 17
  • 69
  • 103
Ajeet Pratap Maurya
  • 4,244
  • 3
  • 28
  • 46
  • This is definitely useful, however I have already determined that the same cookies are being sent as from the browser, for some reason Pandora is doing something strange. If I use any other service, logins work as expected. I even sniffed the http conversation with wireshark, and the cookies sent on the initial request match up perfectly... – quest Dec 03 '11 at 07:14