Question

This can be a little tricky and I'm not sure if it's correct way. Since iOS6 prevent setting cookie in the web container, my legacy HTML5 Django game which rely much on cookie (session id) won't work again. I am trying the cookieless way, write a middleware to bring the sessid out from the url and save it to request.cookies['sess_id']. I works, but the codebase contains alot url dependent logics which are impossible to change one by one... url may look like,

    GET /sess_e4b817ee8993bdcbc34733feb18951ff/m/stage/quest/

now I'm thinking about remove the sess part from the url to make it back to

    GET /m/stage/quest/

and all the on-going process will need no change. I guess I can modified the original property of the django request object. Which property to modify? any other better idea? Thanks.

Was it helpful?

Solution 2

The final way I adopt is to change the iOS container to accept cookie, and no need to change the server side any more. some code for reference,

-(void)applicationDidBecomeActive:(UIApplication *)application {    
isInternetconnectionUp = [self checkInternetConnection];
    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
}

OTHER TIPS

You can just re-include your URLs with a prefix, no need to change anything.

url(r'^(?P<sessionid>sess_[a-f0-9]+)/', include('your_urls')),
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top