* @copyright 2011 Bartolomé Sintes Marco * @license http://www.gnu.org/licenses/agpl.txt AGPL 3 or later * @version 2011-05-19 * @link https://www.mclibre.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ // Función de recogida de datos function recoge($key, $type = "") { if (!is_string($key) && !is_int($key) || $key == "") { trigger_error("Function recoge(): Argument #1 (\$key) must be a non-empty string or an integer", E_USER_ERROR); } elseif ($type !== "" && $type !== []) { trigger_error("Function recoge(): Argument #2 (\$type) is optional, but if provided, it must be an empty array or an empty string", E_USER_ERROR); } $tmp = $type; if (isset($_REQUEST[$key])) { if (!is_array($_REQUEST[$key]) && !is_array($type)) { $tmp = trim(htmlspecialchars($_REQUEST[$key])); } elseif (is_array($_REQUEST[$key]) && is_array($type)) { $tmp = $_REQUEST[$key]; array_walk_recursive($tmp, function (&$value) { $value = trim(htmlspecialchars($value)); }); } } return $tmp; } $admiteCookies = recoge("admiteCookies"); // Si se envía un color se crea la cookie if ($admiteCookies == "") { setcookie("cookiePrueba", "X"); header("Location:cookies-3b.php"); exit; } print "\n"; print "\n"; print "\n"; print " \n"; print " \n"; print " Comprobación de cookies. Cookies.\n"; print " Ejercicios. PHP. Bartolomé Sintes Marco. www.mclibre.org\n"; print " \n"; print " \n"; print " \n"; print "\n"; print "\n"; print "\n"; print "

Comprobación de cookies

\n"; print "\n"; if ($admiteCookies == "1") { print "

El navegador acepta cookies.

\n"; print "\n"; } elseif ($admiteCookies == "0") { print "

El navegador no acepta cookies.

\n"; print "\n"; } else { print "

El navegador no acepta cookies.

\n"; print "\n"; } print "

Comprobar de nuevo

\n"; print "\n"; print " \n"; print "\n"; print "\n"; ?>