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
??
cookie problem
Moderator: General Moderators
-
vivek_dubey
- Forum Newbie
- Posts: 11
- Joined: Tue Oct 20, 2009 1:07 am
cookie problem
Last edited by vivek_dubey on Wed Oct 21, 2009 7:27 am, edited 1 time in total.
Re: cookie problem
Kinda hard to diagnose when you don't provide code or a sample page.
-
vivek_dubey
- Forum Newbie
- Posts: 11
- Joined: Tue Oct 20, 2009 1:07 am
Re: cookie problem
I am not able show the sample
Another what thing i can give
??
Another what thing i can give
??
-
vivek_dubey
- Forum Newbie
- Posts: 11
- Joined: Tue Oct 20, 2009 1:07 am
Re: cookie problem
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]
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
Your cookie needs to have a path.
-
vivek_dubey
- Forum Newbie
- Posts: 11
- Joined: Tue Oct 20, 2009 1:07 am
Re: cookie problem
Thanks for the reply and solution