Verification code problem under session-thinkphp frame
Source: Internet
Author: User
KeywordsFramework session Verification Code PHP
Framework session Verification Code PHP
Public Function myses () { Import ("ORG. Util.date "); $Setime =session (' time '); $Date =new Date; if ($Setime!=null) { $diff = $Date->datediff ("$Setime", "s"); if ($diff >=10) {//Determine if expired $Setime = $Date->dateadd (= ten, $interval = "s");//Set Expiration time Session (' Time ', $Setime);//will expire in session Session (' Rand ', rand (11111,99999)); echo session (' Rand '); Echo 1111;//session exists, but it takes more than 3 minutes to regenerate the verification code } else{ Echo $diff, echo " "; echo session (' time '); echo " "; echo session (' Rand '); echo " ";
echo 2222;//3 minutes again to get the output of the indicator } } else { $Setime = $Date->dateadd (= ten, $interval = "s");//Set Expiration time Session (' Time ', $Setime);//will expire in session Session (' Rand ', rand (11111,99999)); echo session (' Rand '); echo " "; echo session (' time '); echo " "; The Echo 3333;//session value is not set and a new verification code is generated } }
Logic should have no errors, do not know which usage is wrong, because the session is not familiar with, like this by the session to save an expiration time, if the expiration is regenerated. 1, help to change the above code, 2, there is a better way to achieve this function can also
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.