CodeIgniter Forums
Share a variable among sessions - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: Share a variable among sessions (/thread-49784.html)

Share a variable among sessions - El Forum - 03-03-2012

Hi All,

I have a CI application that has to read a given XML file that includes a quite complex structure from a remote server. Every time is read is parsed and store by a model, that then is used from views to represent the information there easily.

But it happens that this XML file is quite large, and rarely changes (it may change a bit, once a week), and I see the time it takes to get from remote server and parse it is long, and may be avoided.

So I thought about storing the model contents somehow on a file, and also store the latest parse date read somewhere, so whenever the model is asked to load the XML file, first it looks at the parse date, and if close, then just reads the parsed data into its properties, instead of http get and parsing.

The XML file is the same for any client session, so that file must be shared among sessions.

What is the best approach in CI to have a "common storage"? Maybe a helper that directly writes on a write-enabled folder? Any other cleaner solution?

Thanks in advance.