Reputation: 7712
This might be impossible but...
I'd like to grab the Request Time of a CURL request just before I send it out. The goal here is to check that the $_SERVER['REQUEST_TIME']
that I receive on the other end is the same as the request time I have when I send it out.
I tried just using
<?php echo time(); ?>
when I send the CURL request, but the time()
function returns a slightly different time locally than the $_SERVER['REQUEST_TIME']
.
Is this possible? Here is my use-case:
I would like to build a nonce that combines the current time and a salt and send it to my server. The server can grab the REQUEST_TIME
and the salt (from the database) to check that the transaction is valid.
Thanks for your help!
Upvotes: 3
Views: 1207
Reputation: 175028
Not doable.
Even if your servers are perfectly synced with their clocks to the millisecond, hardware hiccups, network latency, too many variables for it to reach at the very same second.
Do not use time for salts, generate a strong random one.
As for the actual question, calling time()
will get you the time at the point of execution, right before the curl gets sent.
Upvotes: 6