Run php in Drupal template uncached
Posted
by lokust
on Stack Overflow
See other posts from Stack Overflow
or by lokust
Published on 2010-03-26T20:52:58Z
Indexed on
2010/03/26
23:53 UTC
Read the original article
Hit count: 302
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.
© Stack Overflow or respective owner