-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp23.js
More file actions
43 lines (33 loc) · 1005 Bytes
/
Copy pathapp23.js
File metadata and controls
43 lines (33 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function crearCookie(nombre, valor){
valor = escape(valor)
var hoy = new Date();
hoy.setMonth( hoy.getMonth() + 1);
document.cookie = nombre+"="+valor+";expires="+hoy.toUTCString()+";";
}
function borrarCookie( nombre ){
var hoy = new Date();
hoy.setMonth( hoy.getMonth() - 1);
document.cookie = nombre+"=x;expires="+hoy.toUTCString()+";";
}
function getCookie( nombre ){
var cookies = document.cookie;
var cookieArr = cookies.split("; ");
console.log(cookieArr);
for( var i=0; i < cookieArr.length; i++){
var parArr = cookieArr[i].split("=")
cookieArr[i]= parArr;
if(parArr[0] === nombre){
return unescape(parArr[1])
}
}
console.log(cookieArr)
return undefined;
}
// function borrarCookie(nombre){
// }
crearCookie("nombre","Fernando");
crearCookie("apellido","Lopez");
// borrarCookie("nombre");
console.log(getCookie("apellido"));
// var cookies = document.cookie;
// console.log(cookies);