I have code that get me country flag for user when select country from drop down menu like this
define('WCDP_PATH_INCLUDES', dirname(__FILE__) . '/inc');
if (!class_exists('GeoIP')) {
include(WCDP_PATH_INCLUDES . "/geoip.inc");
}
$geo_data = geoip_open(WCDP_PATH_INCLUDES . "/GeoIP.dat", GEOIP_STANDARD);
$country_code = geoip_country_code_by_addr($geo_data, $_SERVER['REMOTE_ADDR']);
$countrynameselect = $_SESSION['countryname'];
if ($countrynameselect){
$country_code = $countrynameselect;
} else {
$country_code = geoip_country_code_by_addr($geo_data, $_SERVER['REMOTE_ADDR']);
}
// Build HTML for flag icons.
?>
<img src="<? bloginfo('stylesheet_directory')?>/flags/sm/<?php echo strtolower($country_code).'.png'; ?>" border="0" style="margin-top:10px" id="flagc" />
Now when user select country from drop down menu, i save country post in SESSION, But when user change agin, itsh not update SESSION, and to update it, we must refresh page to shpw new SESSION value.
What can i do ??
Aucun commentaire:
Enregistrer un commentaire