Php security string

Source: Internet
Author: User
When writing the cookie value, I checked the cookie files of google and baidu. The value in the files is a long string of characters. therefore, a security string class is written to generate a security string. this is security. php? Php *** @ title security string class * @ authorrainysia * @ version1.0.0 * @ copyrightrainysia

When writing the cookie value, I checked the cookie files of google and baidu. The value in the files is a long string of characters. therefore, a security string class is written to generate a security string. this is security. php? Php/***** @ title secure string class * @ author rainysia * @ version 1.0.0 * @ copyright rainysia

When writing the cookie value, I read the cookie files of google and baidu. The value in the files is a long string, so I wrote a security string class to generate a security string.

This is security. php.

 Len = '40'; * echo $ www-> provideRandString (); * unset ($ www); */class genRandomString {public function provideRandString () {$ chars = array ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'h ', 'J', 'k', 'M', 'n', 'P', 'Q', 'R', 's', 't', 'U ', 'V', 'w', 'x', 'y', 'z', '2', '3', '4', '5', '6 ', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G ', 'H', 'J', 'k', 'l', 'M', 'n', 'P', 'Q', 'R','s ', 'T', 'U', 'V', 'w', 'x', 'y', 'z ','_','#','@', '% ','&','! '); $ CharsLen = count ($ chars)-1; shuffle ($ chars); $ grs = ""; $ len = ""; for ($ I = 0; $ I <$ this-> len; $ I ++) {$ grs. = $ chars [mt_rand (0, $ charsLen)];} return $ grs ;}}?>
In index. php on the logon page, we first include '../lib/security. php ';

After the submit button on the login page, write such a php

 Len = '20'; $ s = $ cookievalue-> provideRandString (); setcookie ("WEB", $ s, time () + 10803 ,"/") or die ("client cookie prohibited");} else {echo "welcome back";}?>
Specifically, WEB_TITLE is defined in the configuration file config. ini. php of the website (define)

A cookie file is generated during login. $ value is generated for this class.


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.