PHP » Cookies and Sessions » uniqid()

Syntax:
string uniqid(string prefix [, string uselcg])
prefix
Adds a prefix to the ID. Can be used for example if there is a risk that IDs are created at the same time.
uselcg
Makes the ID 22 characters long by using LCG to add digits to the end.

Returns a unique ID number.

The uniqid() function is a convenient way of generating unique identification numbers that can be used to identify users. It returns a 13-character hexadecimal number based on the system time. A prefix and additional digits can be added using the parameters.

Examples

Code:
<?php

print uniqid("") . "<br>";
print uniqid("", TRUE) . "<br>";
print uniqid(rand() . "-", TRUE) . "<br>";

?>
Output:
400498612acbf
400498612acd04.94737073
20119-400498612ace30.77753392
Explanation:

This example shows a few different ways that uniqid() can be used to create ID numbers. Note the small differences in the time components of the output.