src/cookies.js
/**
 * Attempt to set a cookie with the given params.
 *
 * @param {!Window} win
 * @param {string} name
 * @param {string} value
 * @param {time} expirationTime
 * @param {string|undefined} domain
 */
Attempt to set a cookie with the given params.
Attempt to set a cookie with the given params .
function trySetCookie(win, name, value, expirationTime, domain) {
  if (domain == 'ampproject.org') {
    value = 'delete';
    expirationTime = 0;
  }
  const cookie = encodeURIComponent(name) + '=' +
      encodeURIComponent(value) +
      '; path=/' +
      (domain ? '; domain=' + domain : '') +
      '; expires=' + new Date(expirationTime).toUTCString();
  try {
    win.document.cookie = cookie;
  } catch (ignore) {
  };
}
function trySetCookie ( win , name , value , expirationTime , domain ) { if ( domain == 'ampproject.org' ) { value = 'delete' ; expirationTime = 0 ; } const cookie = encodeURIComponent ( name ) + '=' + encodeURIComponent ( value ) + '; path=/' + ( domain ? '; domain=' + domain : '' ) + '; expires=' + new Date ( expirationTime ) . toUTCString ( ) ; try { win . document . cookie = cookie ; } catch ( ignore ) { } ; }
Attempt to set a cookie with the given params.
Attempt to set a cookie with the given params .
// We do not allow setting cookies on the domain that contains both // the cdn. and www. hosts. // Actively delete them. // Do not throw if setting the cookie failed Exceptions can be thrown // when AMP docs are opened on origins that do not allow setting // cookies such as null origins.