WEBVTT 00:00:06.860 --> 00:00:10.200 It is video we are going to learn cookies. 00:00:10.230 --> 00:00:12.630 So wants a cookie. 00:00:12.630 --> 00:00:20.460 A cookie is a piece of information that we going to store in the user's computer in a text file. 00:00:20.700 --> 00:00:21.930 And basically it will help. 00:00:21.930 --> 00:00:28.320 The web page to remember some information about the user when they come back later to visit the web 00:00:28.320 --> 00:00:29.250 page. 00:00:29.480 --> 00:00:34.020 So you could be their user name they could be they name and so on. 00:00:34.340 --> 00:00:34.820 OK. 00:00:35.100 --> 00:00:38.260 So how do we add a cookie to use a computer. 00:00:38.520 --> 00:00:44.650 So the syntax is Bookman's dots cookie. 00:00:44.700 --> 00:00:50.130 And we said that to a string. 00:00:50.190 --> 00:00:56.100 And basically inside a string we need a couple of things so we need the property. 00:00:56.620 --> 00:01:03.740 Ok or the variable and then an equal sign of the value of the cookie. 00:01:03.750 --> 00:01:08.890 So actually the cookie is using name and the value of the cookie is pretty Steese. 00:01:09.190 --> 00:01:12.900 OK so we can have 00:01:16.950 --> 00:01:19.090 other cookies on it here. 00:01:19.230 --> 00:01:28.490 So it said the age 2:33 Let's choose for example country Spain races. 00:01:28.950 --> 00:01:31.890 OK so now let's send an alert message 00:01:35.640 --> 00:01:38.990 showing the value of the cookie. 00:01:39.330 --> 00:01:43.000 So it's access the cookie is documents those cookies. 00:01:43.690 --> 00:01:44.400 OK. 00:01:44.430 --> 00:01:51.770 Just bear in mind that's when we use this syntax and we said we use equal sign for documents those cookie 00:01:51.770 --> 00:01:56.110 that doesn't mean that we are setting the the whole cookie to this smiley. 00:01:56.220 --> 00:02:01.980 So this is the syntax to add a a cookie to our cookies. 00:02:01.980 --> 00:02:02.520 OK. 00:02:02.910 --> 00:02:03.990 So let's see what we get. 00:02:04.020 --> 00:02:09.390 In the last message and now you can see that we've got all the cookies because the cookies with their 00:02:09.390 --> 00:02:13.330 values and they are all separated by a semicolon. 00:02:13.960 --> 00:02:16.020 OK. 00:02:16.080 --> 00:02:29.100 All right so now we can try to create an array of items and each item is going to be a cookie with their 00:02:29.160 --> 00:02:29.630 body. 00:02:29.790 --> 00:02:30.050 OK. 00:02:30.090 --> 00:02:30.540 So 00:02:33.240 --> 00:02:42.380 you declare a variable we're going to call this cookie and basically we will use the documents those 00:02:42.390 --> 00:02:49.750 cookie which is shown here and we will use the Split method to create an array. 00:02:50.130 --> 00:02:50.700 OK. 00:02:50.950 --> 00:03:03.570 So documents thought cookie splits and basically we're going to need to have a separate or here we're 00:03:03.580 --> 00:03:05.570 going to use the semi-colon. 00:03:05.600 --> 00:03:12.740 OK because all the cookies and the value they are separated here might be columns. 00:03:12.890 --> 00:03:15.570 All right. 00:03:16.550 --> 00:03:25.140 Now let's alert our array Googie and see what we get 00:03:26.900 --> 00:03:29.400 . 00:03:29.510 --> 00:03:31.070 Refresh the page. 00:03:31.080 --> 00:03:36.290 So now this is the actual list of cookies that we get from the first alerts message. 00:03:36.330 --> 00:03:37.970 Did you document those cookies. 00:03:38.370 --> 00:03:39.300 No. 00:03:39.630 --> 00:03:46.140 This is the array as we see of course all the items on the side are separated by commas and is how arrays 00:03:46.140 --> 00:03:49.000 are showing in last messages. 00:03:49.460 --> 00:03:50.720 OK. 00:03:51.000 --> 00:03:52.890 Now let's try something else let's. 00:03:53.090 --> 00:03:59.320 Aren't all the cookies one by one to our javascript's Biograph. 00:03:59.660 --> 00:04:00.210 OK. 00:04:00.480 --> 00:04:02.400 Following a line break every time. 00:04:02.400 --> 00:04:05.250 So we're going to use a for loop 00:04:07.960 --> 00:04:09.740 and we're going to be doing. 00:04:10.020 --> 00:04:16.330 It's going to be arding So documents first we need to access our program 00:04:19.980 --> 00:04:24.460 and go to the initial e-mail and adding. 00:04:24.750 --> 00:04:39.910 First of all we need a break followed by the item of index in the aere cookie. 00:04:40.030 --> 00:04:54.240 Our variable is initiated the 0 and then we want to be less than the length of the array and every time 00:04:54.670 --> 00:04:56.860 is going up by one. 00:04:57.630 --> 00:04:58.630 OK. 00:04:58.650 --> 00:04:59.450 So let's try this. 00:04:59.460 --> 00:05:05.030 Now that's the list of cookies and this is the array. 00:05:05.260 --> 00:05:12.500 And now we can see that you've got all the cookies are added to our paragraph. 00:05:13.100 --> 00:05:13.730 OK. 00:05:13.830 --> 00:05:22.060 So just to see the usage of the cookies we can delete all our code now. 00:05:23.360 --> 00:05:23.620 OK. 00:05:23.700 --> 00:05:24.930 And just see what happens 00:05:29.070 --> 00:05:31.500 when it's safe. 00:05:31.530 --> 00:05:34.040 And just refresh the page so we don't see anything there. 00:05:34.260 --> 00:05:43.590 So let's see now if we send an alerts message and ask to show all the cookies on the web page. 00:05:43.660 --> 00:05:47.190 Now to see if they are still there. 00:05:47.550 --> 00:05:48.560 So documents 00:05:51.880 --> 00:05:53.040 that cookie 00:05:56.670 --> 00:05:58.210 doesn't as we expected. 00:05:58.230 --> 00:06:04.020 So there really is the whole reason behind using cookies so we know all the values of the cookies they 00:06:04.020 --> 00:06:06.540 are stored on the computer 00:06:06.550 --> 00:06:12.050 .