PhoneGap session (cookies) on iOS

2019-04-20 18:54发布

问题:

On server we have a set of JSON APIs.

There's a login method that authenticates the user and creates user session. Subsequent calls to other methods on the API assume that the user is authenticated.

On client side we have PhoneGap and jQuery mobile. We use ajax calls to communicate with server.

On Android session management is OK, but on iOS after login it seems like the session cookie is not sent back on next call (or is not accepted at all) and the calls fail on server as if the user is not authenticated.

When tested from Safari on the same device everything works fine.

Same behaviour is on iPad 2 with iOS 5.0 and iPhone 4S with iOS 5.1.

Any idea?

回答1:

the problem was with UserAgent string. ASP.NET needs to be configured to accept Mozilla/iOS. See Asp.Net Forms Authentication when using iPhone UIWebView