CONTEXT
I have an index page that displays a list of posts. In addition to having each post identified by a unique ID, I would like each viewing session of a post (i.e. a specific user views a specific post at a specific time) to be unique.
PROBLEM
Is there an easy way to generate a unique ID that identifies the current single-post viewing session, on post load?
I usually use this to generate a 40 char random code. But I guess it depends what you want to use it for.
$new_key = substr(md5(microtime()),0,40);
If it needs to be unique, then I’d check that it’s not currently in use by using a temporary DB.
Alternatively, you can probably use a GUID or UUID.