I want a way to create a sequence of 32-bit tokens that does not repeat and must be guaranteed unique across different sessions.
Preferably pseudo-random but sequential would be OK too.
Although MySQL does not support sequences one possible way is to create a table with an auto_increment column and for a new token insert NULL and then read back last_insert_id, but I would prefer to avoid an extra database write per session.
Any other ideas?
The tokens must be 32-bits long and the method work consistently on 32/64-bit servers without requiring any extensions or privileges beyond a typical default hosting account.
I'm beginning to think the above method may be the only way and would be interested in the thoughts of some more experienced PHP/MySQL developers.