How to create a Genuine user ID in (GUID) PHP


How To Generate A GUID Using PHP?


PHP has the "com_create_guid" function. Since that is a COM function one can assume it leverages internal Window's functionality to obtain a GUID.  Obviously this is useful only on IIS. Refresh the page to obtain a new GUID. A User contributed pseudo GUID generator for non-Windows servers can be found here.


What is a GUID? Excerpt from Wikipedia: "A globally unique identifier or GUID is a special type of identifier used in software applications to provide a reference number which is unique in any context (hence, "globally"), for example, in defining the internal reference for a type of access point in a software application, or for creating unique keys in a database. While each generated GUID is not guaranteed to be unique, the total number of unique keys (2128 or 3.4×1038) is so large that the probability of the same number being generated twice is extremely small."


GUIDs are useful in creating anti-CSRF tokens for web applications. 
GUID: {AE5695A7-E268-4E41-B317-E7E6AF0459C7}


Simple Use: 


<?php
$unique_php_guid = com_create_guid();
echo $unique_php_guid;
?>
sample output:
{BA04C478-4438-43CE-81ED-338F131796A4}



0 comments: