Kiosk Reset Functions

Available functions:

  • resetKioskVisitor() - Reset visitor identity (clears cookies + reloads)

  • checkNewECID() - Check ECID after page reload

  • checkResetResult() - Compare before/after ECIDs

ℹ️ Use Browser Console to access functions and test ECID Reset.

Sample Results after resetKioskVisitor();
checkResetResult();

=== KIOSK RESET VALIDATION ===

Old ECID: 13974310506068227002917455212042850040

New ECID: 02214403502695555490480325463164232035

SUCCESS: Visitor reset worked! New ECID generated.

Kiosk Reset Code

// Kiosk Visitor Reset Function - Clean with Essential Logging
async function resetKioskVisitor() {
  console.log("Kiosk Reset: Starting visitor reset...");
  
  // Get current ECID and store it for comparison after reload
  let currentECID = null;
  try {
    const currentIdentity = await alloy("getIdentity");
    currentECID = currentIdentity.identity.ECID;
    console.log("Current ECID:", currentECID);
    
    // Store in sessionStorage so we can compare after reload
    sessionStorage.setItem('kiosk_reset_old_ecid', currentECID);
  } catch (error) {
    console.log("Could not get current ECID:", error);
  }
  
  // Clear critical Adobe identity cookies
  const criticalPatterns = [/^AMCV_/, /^kndctr_.*_identity$/, /^kndctr_.*_cluster$/];
  let cookiesCleared = 0;
  
  document.cookie.split(';').forEach(cookie => {
    const cookieName = cookie.trim().split('=')[0];
    if (criticalPatterns.some(pattern => pattern.test(cookieName))) {
      console.log("Clearing:", cookieName);
      
      // Clear with multiple domain attempts for reliability
      document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
      document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=${window.location.hostname};`;
      
      const parts = window.location.hostname.split('.');
      if (parts.length > 1) {
        const parentDomain = '.' + parts.slice(-2).join('.');
        document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; domain=${parentDomain};`;
      }
      cookiesCleared++;
    }
  });
  
  console.log(`Cleared ${cookiesCleared} Adobe identity cookies`);
  console.log("Reloading page to reset visitor...");
  console.log("After reload, run: checkResetResult()");
  
  // Reload to reinitialize SDK
  setTimeout(() => window.location.reload(), 1000);
}

// Helper function to check if reset worked (run after page reload)
async function checkResetResult() {
  console.log("=== KIOSK RESET VALIDATION ===");
  
  const oldECID = sessionStorage.getItem('kiosk_reset_old_ecid');
  
  try {
    const newIdentity = await alloy("getIdentity");
    const newECID = newIdentity.identity.ECID;
    
    console.log("Old ECID:", oldECID);
    console.log("New ECID:", newECID);
    
    if (oldECID && oldECID !== newECID) {
      console.log("SUCCESS: Visitor reset worked! New ECID generated.");
    } else if (oldECID === newECID) {
      console.log("FAILURE: ECID remained the same - reset did not work");
    } else {
      console.log("Could not compare - no stored old ECID found");
    }
    
    // Clean up the stored value
    sessionStorage.removeItem('kiosk_reset_old_ecid');
    
  } catch (error) {
    console.log("Error getting new ECID:", error);
  }
}

console.log("Kiosk reset functions loaded!");
console.log("Usage:");
console.log("  1. resetKioskVisitor() - Reset visitor identity");
console.log("  2. After page reloads, run: checkResetResult()");
console.log("");
console.log("The old ECID is automatically stored and compared after reload!");