Menu

#54 Cookies don't work first time

open
None
5
2003-09-19
2003-09-19
Morten Wang
No

Using either session cookies or coming to the site for
the first time will make the menu not show the
expansion states correctly. Only the first item is
interpreted correctly. The offending code is this:

in MDisplayItem

if(MTMUA.cookieEnabled) {
if(MTMFirstRun && MTMCookieString != "") {
item.expanded =
(MTMCookieString.charAt(MTMCookieCharNum++) == "1") ?
true : false;
} else {
MTMCookieString += (item.expanded) ? "1" : "0";
}
}

First item sets MTMCookieString, and subsequently all
following items get their expansion state set to
"false". Not good!

Bugfix will come when all intializing is moved to own
functions (one for DOM-browsers, one for others), then
having one function traverse the tree and set the
expansion-status according to the cookie.

Discussion

  • Morten Wang

    Morten Wang - 2003-09-19

    Logged In: YES
    user_id=141897

    Remember to add default behaviour of overriding cookie if
    makeSubmenu()'s second argument is set to true, or make it
    configurable.

     
  • Morten Wang

    Morten Wang - 2003-09-19

    Logged In: YES
    user_id=141897

    Credits to Jean-Nol (johnxmas) for reporting the bug.

     
  • Morten Wang

    Morten Wang - 2003-09-19

    Logged In: YES
    user_id=141897

    MTMDisplayMenu() doesn't set the cookie when MTMFirstrun is
    true, which it really should. Thought behind current
    behaviour may be that it wasn't necessary to write it first
    time around, but it really is. As it is, user can visit,
    not change anything, and end up having the cookie expire.

     

Log in to post a comment.