ON HASH_EQUALS, TIMING ATTACKS, AND WHY IT MATTERS
PHP added hash_equals in 5.6. That was 2014. Eleven years later, three out of four PHP login handlers I audited this year still use === to compare tokens.
The difference: === short-circuits on the first byte that does not match. The attacker can measure the response time, learn which byte of their guess was right, and walk the token one byte at a time. With enough requests you can extract any secret this way, even with a hash in front of it.
hash_equals compares the entire string in constant time. Slower per call — 190ns vs 4ns for === on a 32-byte token. For a single login it is nothing. For a million-token sweep it is the difference between 4ms and 190ms. And the attacker cannot tell which byte was right.
The code here uses hash_equals on the CSRF token and on the login path. If you are writing a token comparison anywhere else, use it too. Do not write your own.