Can someone tell me why this code is not working. I have and index page where you choose your language using 2 links which lead you to language index pages.
I've added this code to my index page:
<script type="text/javascript">
function get_cookie (username)
{
var results = document.cookie.match(username + '=(.*?)(;|$)');
if (results[1] == "en")
location.replace("http://x.com");
if (results[1] == "es")
location.replace("http://y.com");
else
return null;
}
get_cookie('username');
</script>
And this code to my language index pages:
<script type="text/javascript">
var cookieDate = new Date(2012, 8, 08)
document.cookie = "username=en;expires=" + cookieDate.toGMTString();
</script>
The weird thing is that when I open index page on my desktop it redirects me, but when I open it on web it doesn't.