问题
I have developed a Web Application using Symfony2. I have used FOSUserBundle for user management and security.
Now I am thinking of developing a native iOS APP for my web and don't really know how to approach the issue of creating a session from the APP and mantaign it throughout the interaction user-APP.
In other words, I want to make sure that when I do a NSURLRequest
, somehow the session token is sent to allow the server relate all of the requests in the same session.
Is there anything special to do when creating the session in the PHP side? Is there anything special to do when handling requests from an iOS APP?
Could you mention some good articles to learn on how to get this approach?. I want to do it well from the beggining.
Thanks in advance
回答1:
It's better to rely on a stateless authentication.
On the server side, have a look at the FOSOAuthServerBundle that implements the server side of OAuth2 . The process would be to request the api an access_token from the user credentials, and then pass the access_token on each request.
On the iOS side, I recommend using AFNetworking to make HTTP requests, with AFOAuth2Client to request an access_token.
来源:https://stackoverflow.com/questions/12347319/login-and-mantaign-session-from-ios-app-to-a-symfony2-web-application