Angelo Solla
Angelo Solla

Reputation: 39

php generate token synchronized based on time stamp

this is a question a little complicated, I do not know how I will respond,but i try. how can I generate a random token in php every 30 seconds applies for each client making a request to the server php where is running this script? For example:

User 1 connect to server at 17:30:10 and the token is ABC

User 2 connect to server at 17:30:33 and the token is always ABC

the token must be changed every 30 seconds. how can i implements this?

Upvotes: 0

Views: 891

Answers (2)

Nytrix
Nytrix

Reputation: 1139

Make you're token when connecting, save that in a file or database save the datetime or timestamp too. If there is another load, check if the time has a difference of 30 seconds. Ifso, update the db values and the random key.

Upvotes: 1

tkeram
tkeram

Reputation: 214

You can save the token into cache, or file, dB and set the expiration time to 30 sec

Upvotes: 0

Related Questions