Skip to content

Commit 8f0e73d

Browse files
feat: add cookies
1 parent 7159c60 commit 8f0e73d

File tree

1 file changed

+18
-0
lines changed
  • part9 (Advanced Topics)/client-side-storage

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
INFO: Cookies
3+
Small pieces of data stored in the browser and sent with every HTTP request to the same origin
4+
5+
INFO: Key features:
6+
1. Small (max-4KB)
7+
2. Used for authentication, tracking, etc.
8+
3. Can have expiration, domain, path, and secure flags
9+
4. Accessible via document.cookie.
10+
*/
11+
12+
document.cookie = "username=rafay; expires=Fri, 31 Dec 2025 23:59:59 GMT; path=/";
13+
14+
console.log(document.cookie); // "username=rafay"
15+
16+
document.cookie = "username=admin";
17+
18+
document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC;";

0 commit comments

Comments
 (0)