Problem with cookies
Posted: Tue Dec 02, 2008 1:32 am
hi i am trying to insert cookie in my application.
In above code when i select city the page displayed is indexcity.php
which works fine.
But in indexcity.php displays blank page.
indexcity.php code is following.
It works fine in localhost. but in shared web hosting it displays blank page and no cookie is set.
Please help me.
Thanks in advance.
Code: Select all
<script language="javascript" type="text/javascript">
function Citychange()
{
var city = document.getElementById('cityId').value;
window.location.href="http://www.example.com/Live/indexcity.php?City=" + city;
}
</script>
<select name="city" id="cityId" class="city_texbox" onchange="javascript:Citychange(this.value)">
<option value="" selected="selected">Mumbai</option>
<option value="" selected="selected">New York</option>
<option value="" selected="selected">London</option>
</select>
which works fine.
But in indexcity.php displays blank page.
indexcity.php code is following.
Code: Select all
$city=$_GET['City'];
if(isset($_GET ['City']))
{
if(!isset($_COOKIE['City']))
{
setcookie ("City", $_GET['City'],time()+3600,"/Live");
}
}
if (isset($_COOKIE['City'])) {
echo $_COOKIE['City'] ;
}
Please help me.
Thanks in advance.