You are here

function _favorites_load_favorites_cookie in Favorites 7

Same name and namespace in other branches
  1. 7.2 favorites.module \_favorites_load_favorites_cookie()

Helper function: Load favorites from the user's cookies.

Used to abstract the storage model (cookie vs. db).

Return value

array An array with all favorites as objects, if any.

See also

favorites_load_favorites().

1 call to _favorites_load_favorites_cookie()
favorites_load_favorites in ./favorites.module
Load the favorites for a particular user.

File

./favorites.module, line 505
The favorites module allows users to bookmark any path within a site.

Code

function _favorites_load_favorites_cookie() {
  global $user;
  $ret = array();
  if (!empty($_COOKIE)) {
    foreach ($_COOKIE as $id => $cookie) {
      if (preg_match('/^Drupal_visitor_favorites_(.+)$/', $id, $match)) {
        $ret[] = _favorites_parse_cookie($match[1], $cookie);
      }
    }
  }
  return $ret;
}