Skip to content

Commit 4074f33

Browse files
committed
chore: modify pasteCookie way
1 parent 0cd5fd2 commit 4074f33

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/content-scripts/cache.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ export const cache = {
1010
},
1111

1212
pasteCookie (cookie: string) {
13-
window.document.cookie = cookie
13+
if (!cookie) {
14+
return
15+
}
16+
17+
cookie.split(';').forEach(item => {
18+
const [key, value] = item.split('=')
19+
console.log(key)
20+
const date = new Date()
21+
date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000))
22+
const expires = '; expires=' + date.toUTCString()
23+
document.cookie = key + '=' + (value || '') + expires + '; path=/'
24+
})
1425
},
1526

1627
clearCookie () {

0 commit comments

Comments
 (0)