I am having a bit of an issue, probably over thinking it but i would appreciate any help. I have a main domain. so, domain.com
.. which as a landing page is set to have city names in which you can click on to go to a subdomain.... location1.domain.com
, I am trying to store the link as a variable to call $_COOKIE
.
INDEX.PHP
if($_COOKIE['location'] == "")
{
?>
<body>
<center> Please select your city. </center>
<center> Location 1 </center>
<br><br><br>
<table width="100%">
<tr>
<td width="50%" align="center">
<a href='http://location1.domain.com' onclick="setCookie('location', 'location1',)">location1</a>
<td width="50%" align="center">
<a href="http://location2.domain.com" onlick="SetCookie('location','location2')">location2</a>
</td>
</tr>
</table>
<?
}
else
{
?>
<html>
<head>
<meta http-equiv="refresh" content="0; url=http://"<?$_COOKIE['location']?>".domain.com">';
echo '</head>';
echo '</html>';
<?
}
?>
I want it to be so that when I click on the link that goes from the main index that it saves my selection in a cookie so that next time I visit domain.com it automatically redirects me to my previous choice.. I have also tried using a js to facilitate this but I must not be doing it correctly... everything seems to work except the part where it saves the cookie... thanks in advance!