I have a small http C++ lib which is basically a thin wrapper around libcurl
. I am using this lib to access websites (e.g. login, check/download something, like invoices etc.).
In my latest iOS project, I am also trying to use this libcurl
wrapper to access a website (login, read messages, send messages, its basically a messenger app). However one thing which I cannot get to work is cookies. My intended behaviour would be, that my iOS app (libcurl
, that is) stores cookies after logging in to the website, so that the app does not need to login every time the app is opened.
To achieve this, I tried to set the CURLOPT_COOKIEFILE
and CURLOPT_COOKIEJAR
options to the libcurl
session handle. My understanding was that I should set those options to the same filepath in order for libcurl
to be able to both load and store cookies.
I am setting this path to the full file path of my iOS sandbox documents directory.
However, it seems like the cookie file is never created, and thus the intended behaviour will not work.
Is there anything special to consider, or could anyone give me a hint of what I might be doing wrong?
I am using this build of libcurl
on iOS: https://github.com/sinofool/build-libcurl-ios
That should just work! Does your app have permission to read/write files there? Enable VERBOSE mode and see if libcurl tells you anything. Note that libcurl doesn't write any cookie file until you close the easy handle.