Publicfunctionmyses () {import (& quot; ORG. util. date & quot;); $ Setimesession (& #39; time & #39;); $ DatenewDate; if ($ Setime! NULL) {$ diff $ Date-& gt; dateDiff (& quot; $ Setime & quot;, & quot; s & quot;); if ($ diff & gt; 10) {determine if it expires $ Setime $ Date-& gt; dateAdd ($ number 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) {// determines whether it has expired
$ Setime = $ Date-> dateAdd ($ number = 10, $ interval = "s"); // Set the Expiration Time
Session ('time', $ Setime); // Save the expiration time in the session
Session ('Rand', rand (11111,99999 ));
Echo session ('Rand ');
Echo 1111; // The 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; // Obtain the output ID again within 3 minutes
}
}
Else {
$ Setime = $ Date-> dateAdd ($ number = 10, $ interval = "s"); // Set the Expiration Time
Session ('time', $ Setime); // Save the expiration time in the session
Session ('Rand', rand (11111,99999 ));
Echo session ('Rand'); echo"
";
Echo session ('time'); echo"
";
Echo 3333; // The session value is not set. a new verification code is generated.
}
}
There should be no logic error. I don't know which method is wrong. because I am not familiar with the session, I want to save an expiration time in the session. If it expires, it will be regenerated. 1. help you change the above code. 2. you can implement this function better.