title: Application settings stored as variables - PHP app optimisation
body: <p>I've built an application in PHP that operates on a SaaS multi-tenant architecture. Until now I have a configuration table that has approximately 20 columns - it stores variables such as the language, name, css file location, custom URL and favicon/logo name for each SaaS instance which is then SELECTed as an array in the config file. The config file is included into all scripts and pages.</p>
  
  <p>There has to be a better way to store these variables making them available to the app rather than select 20+ records from a table, set them as variables, using them during the compliation of the PHP script and deliver them to the user. This is adding far more load to my MySQL server than necessary and I dare say it's probably challenging Apache2, too. </p>
  
  <p>What is a good method of achieving this goal? Cookie? Session? XML file?</p>
  
  <p>I'm storing my PHP session ID's in the database and have considered collecting the variables when a user logs in and adding them to a plain text or XML file with the same session ID in the file name. I can then have a cronjob that runs garbage collection on the config files (look for file name X in database and if not found unlink X, in its simplest form).</p>
  
  <p>At the moment, I'm thinking either a cookie or creating a file with the session id containing the values. Either option will remove the need to collect these database values and set them as variables on every page load.</p>
  
  <p>Thoughts and suggestions?</p>
  
  <p>Thank you,
  Michael</p>