Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The sample code below demonstrates reading the cookie and isolating the value of the authenticatedUser value key contained within it.

Code Block
let crumbs = document.cookie.split(';');
  
for(let i = 0; i < crumbs.length; i++) {
    let c = crumbs[i];
    while (c.charAt(0) == ' ') {
        c = c.substring(1);
    }
    if (c.indexOf("authenticatedUser") == 0) {
        let user = c.substring("authenticatedUser".length+1, c.length);
        alert(user);
        return user;
    }
}
return 'Unable to collect user from cookie.';

...