This can be used to authenticate users and generate random passwords--teaman
?
//----------------------------------------------------
Function GetSID ()
//
Parameters: $nSize number of caracters, default 24
return value:24 caracters string
//
Description:this function returns a random string
Caracters that can is used to identify users
On your Web site in a more secure way. You can also
Use this function to generate passwords.
//----------------------------------------------------
function GetSID ($nSize =24) {
If you wish to add numbers in your string,
Uncomment the two lines that are commented
In the IF statement
$nRandom = Mt_rand (1,30);
if ($nRandom <= 10) {
Uppercase letters
$sessionID. = Chr (Mt_rand (65,90));
} elseif ($nRandom <= 20) {
$sessionID. = Mt_rand (0,9);
} else {
lowercase letters
$sessionID. = Chr (Mt_rand (97,122));
}
}
return $sessionID;
}
Test the function
Echo GetSID (16);
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.