If I recall from reading the Mouse book a couple years ago, many of the CGI environment variables such as http_referrer are dependant on the client's browser communicating the necessary information, and any firewalls or anonymizing utilities between the server and the client not stripping away such info. What all those 'ifs' boil down to is that you cannot rely on getting anything meaningful 100% of the time from http_referer.

One solution would be to use cookies (which are also browser dependant). Another would be to use hashed session ID's passed via the URL to maintain session identity. And there are lots of other session management tools as well. http_referer really isn't intended to be used for session management.

If you want a good crash course in CGI and session management, I like the second edition of the Mouse book published by O'Reilly: CGI Programming with Perl. And as for session tools, there is the CGI::Session module on CPAN.

An update to add some trivia:
I was looking into why my spell checker told me that the word is "referrer" and yet the protocol is "referer". Googling turned up the following Wikipedia entry: Referer. In addition to explaining the spelling discrepancy, it also goes on to confirm my suggestion, that http_referer is not a reliable source of information.


Dave


In reply to Re: (OT) http_referer by davido
in thread (OT) http_referer by Anonymous Monk

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.