Revision: 14807
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 12, 2009 09:05 by stancell
Initial Code
class TokenProtection { /** * @param string $name * @return string */ public function getToken($name) { if (!isset($_SESSION['tokenSalt'])) { $_SESSION['tokenSalt'] = mt_rand(1, 1000000); } $token = md5($_SESSION['tokenSalt'] . $name); return $token; } /** * @param string $name * @param string $value * @return bool */ public function isTokenValid($name, $value) { $expectedValue = self::getToken($name); return $value == $expectedValue; } }
Initial URL
Initial Description
Initial Title
PHP token protection
Initial Tags
php
Initial Language
PHP