Example of generating sessionid and random password
Source: Internet
Author: User
The example of generating sessionid and random password can be used to verify the user and generate a random password -- teaman
//----------------------------------------------------
// Function GetSID ()
//
// Parameters: $ nSize number of caracters, default 24
// Return value: 24 caracters string
//
// Description: This function returns a random string
// Of 24 caracters that can be 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 ){
// Randomize
Mt_srand (double) microtime () * 1000000 );
For ($ I = 1; $ I <= $ nSize; $ I ++ ){
// 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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service