File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6+ < title > Document</ title >
7+
8+ < script >
9+ // create a cookie
10+ function setCookie ( name , value ) {
11+
12+ document . cookie = name + "=" + ( value || "" ) + expires + "; path=/" ;
13+
14+ // Set the cookie to expire in 7 days
15+
16+ }
17+
18+
19+
20+ // read a cookie
21+ function get_cookies ( ) {
22+ document . cookie . split ( ';' ) . forEach ( cookie => {
23+ const [ name , value ] = cookie . split ( '=' ) ;
24+ // console.log(name.trim() + ": " + value);
25+ document . write ( name . trim ( ) + ": " + value + "<br>" ) ;
26+ } ) ;
27+ }
28+ </ script >
29+
30+
31+ </ head >
32+ < body >
33+
34+ < button onclick ="get_cookies() "> Get Cookies</ button >
35+ < button onclick ="setCookie('username', 'JohnDoe') "> Set Cookie</ button >
36+
37+ </ body >
38+ </ html >
You can’t perform that action at this time.
0 commit comments