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.