Forum Moderators: coopster
Many thanks!
-----------
Code included at the head of every page in the template:
-----------
<?php
{ if(isset($_COOKIE["geoCode"]))
{ $countryCode = $_COOKIE["geoCode"]; }
else
{ $countryCode = file_get_contents('http://example.com/country.php?ip='.$_SERVER['REMOTE_ADDR']);
setcookie("geoCode", $countryCode, time()+15552000, "/", ".mysite.com", 0); } } ?>
------------
Code that will work if also included in the template, but will not work in PHP Module's
------------
<?php
if( $countryCode == "UK")
{
echo "Hi there UK";
}
else
{
echo "Hello world";
}
?>
[edited by: dreamcatcher at 3:08 pm (utc) on Sep. 22, 2008]
[edit reason] use example.com. Thanks. [/edit]
I'm using a Joomla addon that allows you to include PHP in a module. I am in the UK - if I run the second part of the script as part of the template I get the return message "Hi there UK" showing the geo targeting script is working correctly - but if I include it as part of the PHP module I get the "hello world" reply (its not recognising me as from the UK). I can put it on the page twice, once in the module and once on the template, and get two different replies even though it should be calling on the same information from the cookie?
It seems to be something to do with the way the php is run in the module that stops it from working correctly? Perhaps I need to alter my script to compensate?