Skip to content

Instantly share code, notes, and snippets.

@albertoperezf
Created June 20, 2017 13:59
Show Gist options
  • Save albertoperezf/a3573250ee56a4800a0883d4d22e2c30 to your computer and use it in GitHub Desktop.
Save albertoperezf/a3573250ee56a4800a0883d4d22e2c30 to your computer and use it in GitHub Desktop.
Get JWT from cookie
let cname = 'jwt'
let name = cname + '='
let decodedCookie = decodeURIComponent(document.cookie)
let ca = decodedCookie.split(';')
for (var i = 0; i < ca.length; i++) {
var c = ca[i]
if (c.indexOf(name) === 0) {
console.log('works')
let token = c.substring(name.length, c.length)
} else {
console.log('Error with the cookie')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment