Ciao a tutti,
@elpepe
Ho provato il tuo consiglio
<?php setcookie("test", 45, time()+604800); ?>
ma non funziona
Comunque grazie lo stesso;
@weppos
Gironzolando in Internet ho trovato esattamente
quanto da te detto ma non mi rispondeva alla domanda:
"Perchè a lui nel video funziona senza
"<?php ob_start(); ?> ???
Ho trovato che, nell'esempio proposto, il file php.ini
(a me sconosciuto fino a poche ore fa) aveva questo settaggio:
output_buffering=4096
mentre io
output_buffering = Off
Potevo risolvere il problema cambiando anche io il
settaggio nel php.ini ma ho preferito utilizzare
questo codice:
Codice PHP:
<?php
ob_start();
?>
<html>
<head>
<title>Cookies</title>
</head>
<body>
<?php setcookie('test', 45, time()+(60*60*24*7)); ?>
</body>
</html>
<?php
ob_end_flush();
?>
Anche se c'è il "lato oscuro della forza" ovvero:
"This will turn output buffering on. With output buffering the entire PHP script
will be processed before any output is sent to the client. Thus all the PHP script
will be aware of all the header changes and it will not send any headers until
every line has been processed.ob_start() may appear to slow down the loading
time on server intensive pages, because the client will not be presented with
any fragment of the page until the page is fully processed "
Per ora mi basta, procedo con lo studio di PHP e vediamo cosa salterà fuori.
Grazie a tutti per i consigli.
Ciccio.