note 69720 deleted from function.setcookie by bjori

From: Date: Mon, 08 Jan 2007 10:52:40 +0000
Subject: note 69720 deleted from function.setcookie by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121440@lists.php.net to get a copy of this message
Note Submitter: abdullah dot a at gmail dot com ---- Now, for a non-buggy setcookie that doesn't vanish on Location: redirects. In fact, I suggest you use this instead of the built-in setcookie() function. It also supports "HttpOnly". Usage is the same as the original setcookie() function: <?php function set_cookie($name, $value = '', $expires = 0, $path = '', $domain = '', $secure = false, $http_only = false) { header('Set-Cookie: ' . rawurlencode($name) . '=' . rawurlencode($value) . (empty($expires) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s \\G\\M\\T', $expires)) . (empty($path) ? '' : '; path=' . $path) . (empty($domain) ? '' : '; domain=' . $domain) . (!$secure ? '' : '; secure') . (!$http_only ? '' : '; HttpOnly'), false); } To make a "raw" version of this, get rid of the rawurlencode functions.

« previous php.notes (#121440) next »