Currently creating a plugin with cURL and I need a place that will work for most WordPress servers (Unix or Windows) to store my cookie file. Anyone have a suggestion or best practices? I've been googling for a while now and I think I found something about wp_temp_dir, but googling that keyword gives me only a thousand and one results about solving some install error.


2 Answers 2


Transients seem to be appropriate storage. Just note that if you will generate a lot of this and they will be disposable then you will need to cleanup old transients.

As for your cURL/filename issue - it is bad practice to use cURL directly in WordPress. WP provides HTTP API that abstracts remote requests.

Unfortunately it is bit poorly documented. As far as I understand you pass cookies in arguments array with cookies key to its functions.

  • Got everything to work and recoded everything to use the WordPress HTTP API. This page really helped by the way, planetozh.com/blog/2009/08/… It's a little dated but the info still applies to the new HTTP API on the codex.
    – Thirlan
    Mar 23, 2011 at 4:14

You could store cookies in transients. That way, its absctracted enough from the actual storage location that it should work across environments. Transients are stored in the wp_options table of the database by default, but can be memcached by plugins.

  • I don't know if this works : ( the php cURL code requires that a filename be passed in. curl_setopt($session, CURLOPT_COOKIEFILE, $this->getCookieFile());
    – Thirlan
    Mar 21, 2011 at 1:32
  • How do I move this question by the way? Or do I just have to repost it?
    – Thirlan
    Mar 21, 2011 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.