Page 1 of 1
cookie problem
Posted: Wed Oct 21, 2009 12:43 am
by vivek_dubey
I hv a website url
In this site main menu functionality based on cookie when user click on particular menu the visited menu change its color and cookie is created for that menu and when user click on another city menu previos cookie is deleted
It is working correctly when i use dynamic url like
but when I rewrite url to static
than this function does not work
??
Re: cookie problem
Posted: Wed Oct 21, 2009 2:19 am
by requinix
Kinda hard to diagnose when you don't provide code or a sample page.
Re: cookie problem
Posted: Wed Oct 21, 2009 7:29 am
by vivek_dubey
I am not able show the sample
Another what thing i can give
??
Re: cookie problem
Posted: Thu Oct 22, 2009 1:21 am
by vivek_dubey
This is the code for cookie
This code is for testing purpose
for this my .htaccess entry:
RewriteRule ^file.php/id/2 file.php?id=$1 [NC]
Code: Select all
<script type="text/javascript" language="JavaScript">
function setCookie(cookieName,cookieValue)
{
var today = new Date();
var expire = new Date();
expire.setTime(today.getTime() + 3600000*24*60);
document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
alert(document.cookie);
}
</script>
<ul>
<a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',1);"> Mumbai </a></li>
<li {if $city_id != 2} style="background-image: url(/web/images/tabs/tab-3.gif);" {/if} class="home" title="Delhi">
</li>
<a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',2);" > NCR-Delhi </a></li>
<li {if $city_id != 3} style="background-image: url(/web/images/tabs/tab-4.gif);" {/if} class="home" title="Banglore"><a href="coo.php" onClick="setCookie('city_id',3);"> Bangalore </a></li>
<li {if $city_id != 7} style="background-image: url(/web/images/tabs/tab-5.gif);" {/if} class="home" title="Hydrabad"><a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',7);"> Hyderabad </a></li>
<li {if $city_id != 8} style="background-image: url(/web/images/tabs/tab-6.gif);" {/if} class="home" title="Pune"><a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',8);"> Pune </a></li>
<li {if $city_id != 5} style="background-image: url(/web/images/tabs/tab-7.gif);" {/if} class="home" title="Chennai"><a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',5);"> Chennai </a></li>
<li {if $city_id != 6} style="background-image: url(/web/images/tabs/tab-8.gif);width:109px;" {/if} class="home1" title="Ahmedabad"><a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',6);"> Ahmedabad </a></li>
<li {if $city_id != 4} style="background-image: url(/web/images/tabs/tab-9.gif);" {/if} class="home" title="Kolkata"><a href="/ip/cookietest/coo.php" onClick="setCookie('city_id',4);"> Kolkata </a></li>
</ul>
<li {if $city_id != 4} style="background-image: url(/web/images/tabs/tab-9.gif);" {/if} class="home" title="Kolkata"><a href="/ip/cookietest/file.php/id/2/"> another file </a></li>
</ul>
Re: cookie problem
Posted: Thu Oct 22, 2009 1:18 pm
by requinix
Your cookie needs to have
a path.
Re: cookie problem
Posted: Fri Oct 23, 2009 6:49 am
by vivek_dubey
Thanks for the reply and solution