Run php in Drupal template uncached
- by lokust
Hi. I need to run a php code snippet in a Drupal template and not have it cached.
The php snippet sniffs for a cookie and if found returns one of messages according to the cookie value.
ie:
if(isset($_GET['key'])) { $cookievalue = $_GET['key']; }
if(isset($_COOKIE['cookname'])) { $cookievalue = $_COOKIE['cookname']; }
switch ($cookievalue) { case hmm01: echo "abc"; break; case hmm02: echo "def"; break; case hmm03: echo "ghi"; break; default: echo "hello"; }
Right now, Drupal displays the messages randomly according to when the page was first caches and with which cookie - no good at all!
I can't see a great deal of info on how I might go about this - it seems that you have to turn the cache off for the page rather than run php code uncached.