Since you are using mod_perl, you might as well use apache's mod_unique_id to generate unique IDs for you. From the docs:

This module provides a magic token for each request which is guaranteed to be unique across "all" requests under very specific conditions. The unique identifier is even unique across multiple machines in a properly configured cluster of machines. The environment variable UNIQUE_ID is set to the identifier for each request.

Every request will have $ENV{UNIQUE_ID} set to a unique value.

If for some reason you do not have access to use this module, then you can look at the source code for the implementation that they use to generate a unique ID in an apache environment (remember that in mod_perl2 you may have to deal with a threaded environment).

Update: Just remembered, have a look at Apache::Session::Generate::MD5 for a mechanism similar to yours that Apache::Session uses to generate Session IDs. I would still recommend going with mod_unique_id, but this could be an option for you as well. Please note that you do not need to use Apache::Session in order to use Apache::Session::Generate::MD5...

- Cees


In reply to Re: unique cookie id? by cees
in thread unique cookie id? by rkg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.