Versions Compared

Key

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

GlobalSearch uses a cookie to store the logged in user for the current session. For any number of reasons, you may wish retrieve that user’s login name. Using a Live Field, that data can be easily accessed and become accessible.

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.';

...