You are here

function uc_wishlist_get_uid in UC Wish List 7

Same name and namespace in other branches
  1. 8 uc_wishlist.module \uc_wishlist_get_uid()
  2. 6 uc_wishlist.module \uc_wishlist_get_uid()

Get either an authenticated user's uid or an anonymous user's unique ID.

2 calls to uc_wishlist_get_uid()
uc_wishlist_get_wid in ./uc_wishlist.module
Return the wish list ID of the specified user (defaults to current user).
uc_wishlist_save_wishlist in ./uc_wishlist.module
Save wishlist for the current authenticated or anonymous user.

File

./uc_wishlist.module, line 532
Allows users to create public shopping/wish lists.

Code

function uc_wishlist_get_uid() {
  global $user;

  // Get either an authenticated user's uid or an anonymous user's unique ID.
  if ($user->uid) {
    $uid = $user->uid;
  }
  else {
    if (!isset($_SESSION['uc_wishlist_uid']) || empty($_SESSION['uc_wishlist_uid'])) {
      $_SESSION['uc_wishlist_uid'] = md5(uniqid(rand(), TRUE));
    }
    $uid = $_SESSION['uc_wishlist_uid'];
  }
  return $uid;
}