note 41591 added to function.setcookie

From: Date: Thu, 15 Apr 2004 19:37:03 +0000
Subject: note 41591 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-68176@lists.php.net to get a copy of this message
It's a function to make easy the expiration date of a cookie <? function easycookie($nombre, $contenido, $duracion){ /* $nombre is the name of the cookie $contenido is the cookie value $duracion must have the form: amount space measure unit the measure unit can be hour (h), day (d), month (m), year (y) or minute (min) Examples: easycookie("id", "eRh65GcdN7", "2 m") will expire after 2 months easycookie("lang", "es", "1 y") will expire after 1 year */ $a = explode(" ", $duracion); $unidad = $a[1]; $cantidad = $a[0]; switch ($unidad){ case "min": $duraciondefinitiva = time() + ($cantidad * 60); break; case "h": $duraciondefinitiva = time() + ($cantidad * 3600); break; case "d": $duraciondefinitiva = time() + ($cantidad * 86400); break; case "m": $duraciondefinitiva = time() + ($cantidad * 2678400); break; case "y": $duraciondefinitiva = time() + ($cantidad * 31536000); break; } setcookie($nombre, $contenido, $duraciondefinitiva); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41591 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41591&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41591&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68176) next »