Async Cookie Store API, khả dụng từ Chrome 87
(medium.com)-
Thay thế
document.cookietheo cách cũ -
Trả về Promise nên cũng có thể dùng trong Service Worker
-
Truy cập trực tiếp theo từng cookie, không cần tìm qua vòng lặp
-
Đăng ký event listener để theo dõi thay đổi cookie
→ await cookieStore.get('session_id')
→ await cookieStore.set({ name: 'opt_out', value: '1' });
→ await cookieStore.delete('session_id');
→ cookieStore.subscribeToChanges([{ name: 'session_id' }])
Chưa có bình luận nào.