private void setStatesAndBindCookies(CookieType candidateType, ZombieCookie candidateCookie) { CookieStates states = getCookieStates(); ZombieCookie currentCookie = getZombieCookie(); if (currentCookie.hasParent()) { // The current selected zombie cookie, in theory, could have a // new parent inserted from a seperate simultaneous page load // in a different HTTP session. We don't have a seperate state // name for this, but in practice we never see it either. currentCookie = currentCookie.oldestRelative(); log.error("found unexpected parent cookie={}", currentCookie.getId()); } boolean usingCandidateParent = false; if (candidateCookie.hasParent()) { usingCandidateParent = true; candidateCookie = candidateCookie.oldestRelative(); } if (candidateCookie.isOlder(currentCookie)) { states.set( candidateType, usingCandidateParent ? replacedFromOlderState(candidateType) : EXISTING); cascadeNewBestCookie(candidateType); } else { // Pick a replacementent state for the candidate cookie setHowCookieWasReplaced(candidateType); } // If the incomming candidate cookie had a parent equal to the current // cookie, we don't have to set a new value. if (!currentCookie.getId().equals(candidateCookie.getId())) { setAndSaveZombieCookie(currentCookie.linkTo(candidateCookie)); } }