php - Insert value to URL path -
i have site content different market locations, setting cookie users location. if user tries going landing page directly insert market location url.
for example, if user tries going www.mysite.com/packages
update url www.mysite.com/tampa/packages
i have cookie set called "market", , code trying, isn't working.
<?php switch ($_cookie['market']) { case "tampa": $url = $_server['request_uri']; switch (true) { case strstr($url, 'packages'): $currenturl = str_replace('/packages','/tampa/packages/',$url); return $currenturl; break; } break; // etc other markets }
is php right approach this? there better solution work? thank in advance help.
you need use header()
function reload webpage new url so:
instead of:
return $currenturl;
do:
header('location: '.$currenturl);
be sure there's no output browser before doing though.
Comments
Post a Comment