January 11, 2011

UUID Generator PHP


function getUUID($prefix = '')
{
$chars = md5(uniqid(mt_rand(), true));
$uuid = substr($chars,0,8) . '-';
$uuid .= substr($chars,8,4) . '-';
$uuid .= substr($chars,12,4) . '-';
$uuid .= substr($chars,16,4) . '-';
$uuid .= substr($chars,20,12);
return $prefix . $uuid;
}

// php with Cookie and 30 days expiration.
setcookie("uuid_sithi",$row_login->cookie,time()+(60*60*24*30));

Thank ajaxray