private static function parseVals($key, $val, $prefix, $ikey, $time = null)
{
$ts = $time ? $time : time();
$parts = explode('|', $val);
if (count($parts) !== 3) {
return null;
}
list($u_prefix, $u_b64, $u_sig) = $parts;
$sig = hash_hmac("sha1", $u_prefix . '|' . $u_b64, $key);
if (hash_hmac("sha1", $sig, $key) !== hash_hmac("sha1", $u_sig, $key)) {
return null;
}
if ($u_prefix !== $prefix) {
return null;
}
$cookie_parts = explode('|', base64_decode($u_b64));
if (count($cookie_parts) !== 3) {
return null;
}
list($user, $u_ikey, $exp) = $cookie_parts;
if ($u_ikey !== $ikey) {
return null;
}
if ($ts >= intval($exp)) {
return null;
}
return $user;
}