Error al crear cookie
Publicado por jose (71 intervenciones) el 12/05/2021 19:33:55
Buenas tardes,
Tengo un problema al crear cookie. Veo que sale el mensaje "Cookie named 'Gestion_Cookie' is not set!" en todas las páginas
Este es el código. He visto mucha información y videos de youtube y veo que está normal.
La página se aloja en un servidor interno con la ip 192.168.2.2 en /volume1/web/gestion/
También he dejado comentado if(isset($time)) dado que sino no es posible logarse.
No entiendo muy bien donde puede estar el fallo. Alguien podría aclararme que ocurre.
Archivo cookie.php
Archivo logout.php
En todas las páginas he colocado al inicio lo siguiente:
Tengo un problema al crear cookie. Veo que sale el mensaje "Cookie named 'Gestion_Cookie' is not set!" en todas las páginas
Este es el código. He visto mucha información y videos de youtube y veo que está normal.
La página se aloja en un servidor interno con la ip 192.168.2.2 en /volume1/web/gestion/
También he dejado comentado if(isset($time)) dado que sino no es posible logarse.
No entiendo muy bien donde puede estar el fallo. Alguien podría aclararme que ocurre.
Archivo cookie.php
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
<?php
//Name of the cookie
$cookie = "Gestion_Cookie";
//The value which will be stored in the cookie
$value = "Gestion J&J";
//How long the cookie will be set for
$current_Time=time();
$time=time()+60;
//The folder and scope that it is available in
$path ="/volume1/web/gestion/";
//The domain name is available in
$host="192.168.2.2";
//1 = Available only in https secure web domain names
//0 = Available in all domains
$security = 1;
setcookie($cookie,$value,$time,$path,$host,$security);
if (isset($_COOKIE[$cookie])){
print "current time: '".$time. "'";
print "Cookie '" . $cookie . "' is set!<br>";
print "Previous Visit Time: '". $_COOKIE[$cookie]. "'";
print "Value is: : '". $COOKIE[$cookie]. "'";
} else {
print "Cookie named '" . $cookie . "' is not set!";
}
/*if(isset($time)){
session_destroy();
header("Location:../index.php");
ob_end_flush();
}*/
?>
Archivo logout.php
1
2
3
4
5
6
7
<?php
ob_start();
session_start();
session_destroy();
header("Location:../index.php");
ob_end_flush();
?>
En todas las páginas he colocado al inicio lo siguiente:
1
2
3
4
5
6
7
<?php
require('../../session/cookie.php');
ob_start();
session_start();
if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
header("location:../../index.php");
}
Valora esta pregunta


0