public static function secureCookieBasic::get in Secure Cookie Data 7.2
Getter for the class.
Return value
object The stored data or NULL if the cookie is missing or the HMAC doesn't validate.
2 calls to secureCookieBasic::get()
- secureCookieTreeTwo::delete_node in modules/
secure_cookie_data_tree_two.class.inc - Removes a certain node from the tree stored as cookie data.
- secure_cookie_data_get in ./
secure_cookie_data.module - Obtain the data stored in a secure cookie.
File
- ./
secure_cookie_data.class.inc, line 162 - secure_cookie.class.inc @author António P. P. Almeida <appa@perusio.net> @date Wed Dec 21 03:17:53 2011
Class
Code
public static function get() {
if (isset($_COOKIE[static::$__cookie_name])) {
// Decode the JSON.
$cookie_data = secureCookieBasic::decode($_COOKIE[static::$__cookie_name]);
// Next we get the HMAC.
if (isset($cookie_data->hmac)) {
$hmac = $cookie_data->hmac;
// Unset the hmac entry so that we get the 'raw' data only.
unset($cookie_data->hmac);
// Validate the cookie using the HMAC stored on the data.
if (secureCookieBasic::validate($hmac, $cookie_data)) {
// Return the data.
return $cookie_data;
}
}
}
return NULL;
}