4

Just looking for a little clarification on the craft()->fileCache method...

Everybody already knows that when a cookie is set, that cookie only exists on the end-user's computer. No one else using the website can access that cookie.

But if I were to replace that cookie getter/setter with the craft()->fileCache getter/setter methods, is that data now available to everyone? Where a cookie is stored on the client machine, the fileCache data is stored on the server?

This is what I suspect is happening, just trying to be sure that I'm interpreting this correctly.

7

Correct... craft()->fileCache will save to your craft/storage/runtime/cache folder by default, which will have a .bin file that has a hash of the key you provided when calling set() and the contents will be a serialized version of the value you passed in.

Also worth noting that while craft()->fileCache still exists, as of Craft 2.0, it is simply a shortcut to craft()->cache, when the cacheMethod config setting is set to file.

3
  • Great, thanks Brad! To clarify further... if I use fileCache then I'm determining at the plugin level where the data will get saved, but if I just use cache it will default to wherever the website's config file specifies. Is that correct?
    – Lindsey D
    Jun 30 '14 at 18:43
  • 1
    Yup... nailed it.
    – Brad Bell
    Jun 30 '14 at 20:06
  • Awesome, thanks man!
    – Lindsey D
    Jun 30 '14 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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