You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should have heard about cookie while using a website, which always pops up at you, and some people say it is harmfull because it collects data from us.
3
+
Let's get indepth of cookie...
4
+
>> Cookies are data, stored in small text files on your computer
5
+
> Cookies were invented to solve the problem of "how to remember information about the user"
6
+
> when a user visits a web page his name can be stored in a cookie
7
+
> next time the user visits the web page he can remember his name
8
+
We will try by our first Example
9
+
10
+
Example 1:
11
+
*/
12
+
lettextOne=document.getElementById('textOne');
13
+
14
+
letrememberPersonOne=document.cookie="username= John Doe";
15
+
16
+
textOne.innerHTML=rememberPersonOne;
17
+
18
+
// Cookies can be changed or deleted the same way that they have been created
19
+
// for Example
20
+
document.cookie="username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
21
+
22
+
23
+
/* Now there are three main functions of cookies
24
+
1. setCookie()
25
+
2. getCookie()
26
+
3. checkCookie()
27
+
*/
28
+
29
+
// In this Example we will discuss about how to setCookie()
0 commit comments