How does php determine to give a user a gold coin once a day ?? How does php determine to give a user a gold coin once a day ??
Reply content:
How does php determine to give a user a gold coin once a day ??
Session (user identification) + database (whether the current time falls within the time range of the day determined by the last gold coin sending time => whether the current time exceeds the upper limit of the time range of the day determined by the last gold coin sending time, use timestamp for addition, subtraction, and so on)
If it is not very strict, use cookies. If it is necessary to strictly create a database field value for the day
On the server side, record the time stamp for sending gold coins. If the time stamp is the same day, it indicates that the gold coins have been sent.
$ Today = new DateTime ('today'); if (is_null ($ user-> givedtime )) {// never sent at a time} else if (strtotime ($ user-> givedtime) >=$ today-> getTimestamp ()) {// sent on the same day} else {// never sent on the same day}