iannorthwood
Technical User
I have implemented a JS cookie solution but have a problem. I use it as a record of the user preference for tooltips: clicking a form button toggles them on and off. That all works. I can toogle on/off to my heart's content.
Here's the problem: the cookie which gets written if the page is called without a query string is named as 'username@localhost(1).txt' with these contents:
AppDB_TooltipToggle
off
localhost/
1088
2227004672
29763393
205713472
29689968
*
However, if the page is called with a query string (I call functions this way, as I want to use the same page format for different results), a cookie written as 'username@SSGPSIT(1).txt' with these contents:
AppDB%5FFormBasedQuery
[SQL query goes in here]
localhost/SSGPSIT
1024
986760704
29691376
307903472
29689968
*
where 'SSGPSIT' is the virtual dir name.
Now, with the above cookie in place, clicking the button calls the function OK (I test it with an alert window) but the cookie returns null, even though the cookie name is the same (I use a variable to ensure that!). Also, no NEW cookie gets written to reflect the new status but that's presumably because the code only toggles if it sees a return value of 'on' or 'off'. The toggle function is reproduced below.
I *know* the above is a different cookie but why isn't the existing tooltip cookie being read? Do I need to reference the VD in the cookie name somehow?
To reiterate, there is NO problem per se with writing cookies from the page, nor reading them: the problem is that if the page is called with a QueryString in it, the virtual directory name gets used, which seems to make it a different cookie, so far as the bnrowser's concerned.
Here's the problem: the cookie which gets written if the page is called without a query string is named as 'username@localhost(1).txt' with these contents:
AppDB_TooltipToggle
off
localhost/
1088
2227004672
29763393
205713472
29689968
*
However, if the page is called with a query string (I call functions this way, as I want to use the same page format for different results), a cookie written as 'username@SSGPSIT(1).txt' with these contents:
AppDB%5FFormBasedQuery
[SQL query goes in here]
localhost/SSGPSIT
1024
986760704
29691376
307903472
29689968
*
where 'SSGPSIT' is the virtual dir name.
Now, with the above cookie in place, clicking the button calls the function OK (I test it with an alert window) but the cookie returns null, even though the cookie name is the same (I use a variable to ensure that!). Also, no NEW cookie gets written to reflect the new status but that's presumably because the code only toggles if it sees a return value of 'on' or 'off'. The toggle function is reproduced below.
I *know* the above is a different cookie but why isn't the existing tooltip cookie being read? Do I need to reference the VD in the cookie name somehow?
Code:
// elsewhere on page, I set the cookie name:
var tooltip_cookie_name = "AppDB_TooltipToggle";
// this is what the button click calls
// ShowToolTips is a variable used by the tooltip library (overLib, actually - excellent!)
function TooltipToggle()
{
var tipToggle = readCookie(tooltip_cookie_name);
if(!tipToggle)
{
createCookie(tooltip_cookie_name,'on',365);
ShowToolTips = true;
alert("Tooltips are now on");
}
if (tipToggle == 'on')
{
createCookie(tooltip_cookie_name,'off',365);
ShowToolTips = false;
alert("Tooltips are now off");
}
else if (tipToggle == 'off')
{
createCookie(tooltip_cookie_name,'on',365);
ShowToolTips = true;
alert("Tooltips are now on");
}
}
To reiterate, there is NO problem per se with writing cookies from the page, nor reading them: the problem is that if the page is called with a QueryString in it, the virtual directory name gets used, which seems to make it a different cookie, so far as the bnrowser's concerned.