use Digest::MD5; $session_id = substr(md5_hex(md5_hex(time() . {} . rand() . $$)), 0, 32);