Join Up!
96811 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previoussleepunpacknext
Last updated: Tue, 29 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to Czech | German

uniqid

(PHP 3, PHP 4 )

uniqid -- Genera un id único.

Descripción

int uniqid ( string prefix [, boolean lcg])

uniqid() devuelve un identificador único con un prefijo basado en la hora actual en microsegundos. El prefijo puede ser práctico por ejemplo si se generan identificadores simultáneamente en varios host que pueden haber generado el identificador en el mismo microsegundo. prefix (prefijo) puede ser de hasta 114 carácteres de longitud.

Si el parámetro opcional lcg es TRUE, uniqid() añadirá entropía "LCG combinada" al final del valor devuelto, que hará el resultado más único.

Con un prefix (prefijo) vacío, la cadena devuelta tendrá una longitud de 13 carácteres. Si lcg es TRUE, tendrá 23 carácteres.

Nota: El parámetro lcg está disponible sólo en PHP 4 y PHP 3.0.13 y posteriores.

Si necesita un identificador único o testigo, y tiene la intención de hacer público ese testigo al usuario por medio de una red (i.e. cookies de sesión) se recomienda que utilice algo parecido a estas líneas

$token = md5(uniqid("")); // no random portion
$better_token = md5(uniqid(rand())); // better, difficult to guess

Esto creará un identificador de 32 carácteres (un número hexadecimal de 128 bits) que es extremadamente difícil de predecir.

User Contributed Notes
uniqid
add a note about notes
There are no user contributed notes for this page.
previoussleepunpacknext
Last updated: Tue, 29 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST