[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] =?utf-8?q?svn:_/phpdoc/en/trunk/reference/misc/functions/_uniqid.xml?=
From: Kalle_Sommer_Nielsen <kalle () php ! net>
Date: 2009-12-25 0:24:47
Message-ID: svn-kalle-1261700687-292616-500468742 () svn ! php ! net
[Download RAW message or body]
kalle Fri, 25 Dec 2009 00:24:47 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=292616
Log:
Fixed bug #50471 (uniqid example is bad)
Bug: http://bugs.php.net/50471 (Open) uniqid example is bad
Changed paths:
U phpdoc/en/trunk/reference/misc/functions/uniqid.xml
Modified: phpdoc/en/trunk/reference/misc/functions/uniqid.xml
===================================================================
--- phpdoc/en/trunk/reference/misc/functions/uniqid.xml 2009-12-25 00:16:22 UTC (rev 292615)
+++ phpdoc/en/trunk/reference/misc/functions/uniqid.xml 2009-12-25 00:24:47 UTC (rev 292616)
@@ -62,24 +62,27 @@
<refsect1 role="examples">
&reftitle.examples;
<para>
- If you need a unique identifier or token and you intend to give
- out that token to the user via the network (i.e. session cookies),
- it is recommended that you use something along these lines:
- </para>
- <para>
- This will create a 32 character identifier (a 128 bit hex number)
- that is extremely difficult to predict.
<example>
<title><function>uniqid</function> Example</title>
<programlisting role="php">
<![CDATA[
<?php
-// no prefix
-// works only in PHP 5 and later versions
-$token = md5(uniqid());
+/* A uniqid, like: 4b3403665fea6 */
+printf("uniqid(): %s\r\n", uniqid());
-// better, difficult to guess
-$better_token = md5(uniqid(mt_rand(), true));
+/* We can also prefix the uniqid, this the same as
+ * doing:
+ *
+ * $uniqid = $prefix . uniqid();
+ * $uniqid = uniqid($prefix);
+ */
+printf("uniqid('php_'): %s\r\n", uniqid('php_'));
+
+/* We can also active the more_entropy parameter, which is
+ * required on some systems, like Cygwin. This makes uniqid()
+ * produce a value like: 4b340550242239.64159797
+ */
+printf("uniqid('', true): %s\r\n", uniqid('', true));
?>
]]>
</programlisting>
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic