Unique ID per request
Created: Last updated:
If you need a unique request ID for each webpage and you run an Apache web server you are all set. There is no need to generate or create a unique request id yourself in PHP, ASP, Ruby or whatever.
mod_unique_id
Apache has a module labeled mod_unique_id that provides a unique request id for each webpage access from your website. If the module is loaded (active) you can find the unique ID in your server and execution environment information. In PHP this would be the global $_SERVER array as follows
$_SERVER['UNIQUE_ID']
Not sure about other languages but I guess you will know where to look for it.
If you already know and have the UNIQUE_ID on one system but it is empty and not available on another system then it is not loaded (commented out) in your httpd.conf file. The module is usually not loaded by default.
Note in the documentation that is says This feature isn't supported on Windows NT. I have an XAMPP server on Windows XP and it available so I guess they refer to the good ol' NT 4.0 times. If you have Apache on Windows just give it a try if you don't have it yet. Again it is usually not loaded by default.
Language and framework independent
Because this is coming from your Apache web server there is no need to generate a unique ID with uniqid in PHP. There is also no need to handle or find it in Zend, WordPress, Joomla, Drupal, Cake or any other framework.
The same is true, of course, for other web languages like Perl, ASP, Ruby or whatever language you are using.