Cookies with libcurl for Cocos2d-x instead of NSHTTPCookieStorage.

Hello,

I have a game I’m porting from iOS Objective-C to Cocos2d-x. Part of the game is sending server requests and getting authorization using cookies and whatnot.

The iOS code worked like a charm but I am having problems porting the code to C++. Here is the Objective-C working code I need to import:

NSMutableDictionary cookieProperties = ;
;
;
;
;
;
;
dateByAddingTimeInterval:2629743] forKey:NSHTTPCookieExpires];
NSHTTPCookie
cookie = [NSHTTPCookie cookieWithProperties:cookieProperties];
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];

[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

Now for Cocos2d-x I don’t know what exactly I have to do! I tried this:

curl_easy_setopt(curl, CURLOPT_COOKIEFILE, “”);
curl_easy_setopt(curl, CURLOPT_COOKIE, “NSHTTPCookieName=authenticatedUser; NSHTTPCookieValue=lll@lll.com; NSHTTPCookieDomain=game.example.me; NSHTTPCookieOriginURL=game.example.me; NSHTTPCookiePath=/; NSHTTPCookieVersion=0; NSHTTPCookieExpires=9999”);

But it’s not working. I send post requests using HttpClient.cpp from the network extension and I added this code there as well so the cookie gets sent everytime but I don’t think I properly understand how this whole cookie thing works.

Any help is appreciated! Thank you! :slight_smile: