Skip to content

Instantly share code, notes, and snippets.

@latel
Created June 28, 2018 00:12
Show Gist options
  • Save latel/c1c0acc717d6b31dfedaf8a30825493d to your computer and use it in GitHub Desktop.
Save latel/c1c0acc717d6b31dfedaf8a30825493d to your computer and use it in GitHub Desktop.
make document.cookie as json
var domain = location.host, jsonCookie = [];
document.cookie.split(';').forEach(cookie => {
let [ name, value] = cookie.trim().split('=');
jsonCookie.push({ name, value, domain,
expirationDate: 8880000000,
hostOnly: false,
httpsOnly: false,
path: '/',
sameSite: 'no_restriction',
secure: false,
session: false,
storeId: '0'
});
});
console.log(jsonCookie);
console.log('======复制黄色部分=========');
console.warn(JSON.stringify(jsonCookie));
console.log('======复制黄色部分=========')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment