Email conversation
From | Eric Steinborn |
To | Me |
Subject | Cookie script saving seperate cookies past root folder |
Date | 19 June 2007 15:14 |
Hi,
Your scripts are awesome. And I have been using 2 of them on my internal
intranet for our redesign. The cookies script works wonderfully when the
html files are in the same folder but when you move to another folder
they use their own cookies, and therefore settings. As an example:
Saves open/close states of files in same directory:
c:\index.html c:\foo.html c:\bar.html
But once you go one folder deep they rely on their own cookie and save
individual data:
c:\foo\index.html c:\bar\index.html save separate cookies.
I've been trying for 3 days to figure out exactly what is happening
here.
This step is crucial to the implementation of the collapsible
navigation. Is there a way possibly, to tell the cookie to not bother
with the path or domain and just have it pull the open/close data from
the root cookie and update/display it site wide?
Right now the cookie script is unedited:
http://www.howtocreate.co.uk/tutorials/jsexamples/cookies.html
These are at the top of my html file:
<script type="text/javascript" src="js/listcollapse.js"></script>
<script type="text/javascript" src="js/cookie.js"></script>
And in a file like c:\foo\index.html it looks like:
<script type="text/javascript" src="../js/listcollapse.js"></script>
<script type="text/javascript" src="../js/cookie.js"></script>
But each group uses a different cookie.
Any help you could provide would be greatly appreciated.
If you need any more code examples I can give them to you. But the
navigation is exactly how you said to write it in the html. As well as
the collapsiblelist script is 100% unedited.
Again thanks for the amazingness that is your site :)
-Eric Steinborn
From | Me |
To | Eric Steinborn |
Subject | Re: Cookie script saving seperate cookies past root folder |
Date | 20 June 2007 13:45 |
Eric,
> The cookies script works wonderfully when the
> html files are in the same folder but when you move to another folder
> they use their own cookies, and therefore settings.
This is controlled by the 'path' parameter when you call setCookie. You
probably want to pass it '/' - meaning "the whole site". You would want
something like this:
setCookie('menuState',stateToFromStr('someID'),null,'/');
(or use a number instead of null if you want a cookie that lasts for an
amount of time instead of the browser session)
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Eric Steinborn |
To | Me |
Subject | Re: Cookie script saving seperate cookies past root folder |
Date | 20 June 2007 18:29 |
Thank you! That worked exactly the way I needed it to. Many many many
thanks!
-Eric Steinborn