-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblema1.php
More file actions
40 lines (36 loc) · 1.18 KB
/
problema1.php
File metadata and controls
40 lines (36 loc) · 1.18 KB
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
<?php
/**
* APARTADO A
*/
// Primero recibimos la información del form y vemos si exise la cookie o no
if (isset($_COOKIE["user"])) {
// Si nuestro navegador contiene cookies, actualizamos el tiempo de vida de nuevo a una semana
setcookie("usuario",$_COOKIE["user"],time()+3600*24*7);
} else{
iniciarSesion();
}
function iniciarSesion(){
//setcookie("usuario",1,time()+3600*24*7);
echo '<from action="procesarForm.php" method="POST>"';
echo '<input type="text" name="username">';
echo '<input type="password" name="password">';
echo '</form>';
}
/**
* APARTADO B
*/
// Primero recibimos la información del form y vemos si exise la cookie o no
if (isset($_COOKIE["username"])) {
// Si nuestro navegador contiene cookies, actualizamos el tiempo de vida de nuevo a una semana
setcookie("usuario",$_COOKIE["user"],time()+3600*24*7);
temaLeido();
} else{
iniciarSesion();
}
function temaLeido(){
$nombreCookie = "cesta_de_".$_COOKIE["user"];
echo '<style>
a.Tema:visited{color: blue}
</style>';
}
?>