Examples of generating sessionid and random passwords _php tutorial

Source: Internet
Author: User
Tags add numbers
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
of caracters that can is used to identify users
On the your Web site in a more secure the. You can also
Use the 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 lines that is 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);
?>

http://www.bkjia.com/PHPjc/316378.html www.bkjia.com true http://www.bkjia.com/PHPjc/316378.html techarticle Use this to authenticate users and generate random passwords--teaman?//----------------------------------------------------//Function GetSID ()//// Parameters: $nSize number of caracte ...

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.