Sha256: 417bf9c47c62f1313dffe0d6d9b6b61b378951e8deaeb91d02457a7784fc540b

Contents?: true

Size: 605 Bytes

Versions: 13

Compression:

Stored size: 605 Bytes

Contents

export function getCookie (name) {
  name += '='

  var cookies = document.cookie.split(/;\s*/)

  for (let i = cookies.length - 1; i >= 0; i--) {
    if (!cookies[i].indexOf(name)) {
      var value = cookies[i].replace(name, '')
      return decodeURIComponent(value)
    }
  }

  return ''
}

export function setCookie (name, value) {
  document.cookie = `${name}=${encodeURIComponent(value)}; path=/`
}

export function deleteCookie (name) {
  document.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`
}

export default {
  get: getCookie,
  set: setCookie,
  delete: deleteCookie
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trestle-0.10.1 frontend/js/core/cookie.js
trestle-0.10.0 frontend/js/core/cookie.js
trestle-0.10.0.pre2 frontend/js/core/cookie.js
trestle-0.10.0.pre frontend/js/core/cookie.js
trestle-0.9.8 frontend/js/core/cookie.js
trestle-0.9.7 frontend/js/core/cookie.js
trestle-0.9.6 frontend/js/core/cookie.js
trestle-0.9.5 frontend/js/core/cookie.js
trestle-0.9.4 frontend/js/core/cookie.js
trestle-0.9.3 frontend/js/core/cookie.js
trestle-0.9.2 frontend/js/core/cookie.js
trestle-0.9.1 frontend/js/core/cookie.js
trestle-0.9.0 frontend/js/core/cookie.js