Warning: I have little to say of a practical nature here. I'll just try to explain why what you think you want to do is probably not the way you should try to do it.

The URL of the referring page is not specifically a creature of the CGI protocol (it's defined by the HTTP protocol) the referrer is passed *to* the webserver by the client (the browser)1, so an uncooperative client needn't provide that information. The environment variable REFERER, which is available to CGI programs, is where to look. In Perl, that's in the %ENV hash, i.e. $ENV{REFERER} holds the value of this variable.

The REFERER (yeah, that's how it's misspelled =) history isn't quite the same as the browser's history, either. Basically, the idea is that you have to follow a link, submit a form, or be redirected from a page to the current page for it to be the REFERER of the current page (so, e.g. if you type in a new URL, the page you were on when you typed that URL in will *not* be the referer of the new page; but it will be the previous one in your browser's history list, and it will be the one your browser attempts to display if you hit the "back" button). Otherwise, the value of REFERER is generally available to the server and (e.g.) can be included in the webserver's logs. You'll have to check with the admin of your webserver if you want that kind of information. There are log analysis tools that attempt to track the length of a client's "sessions" but they rely on a range of strategies, not just the referrers.

I don't believe that even with browsers that implement Javascript, the history is *by default* available to you. And if it is (and it may well be, it's been a while since I checked this sort of thing), that's criminally bad design.

Given all those caveats, if you *must* track user's progress ... and I'll assume you don't have nefarious purposes in mind -- is to do it from the server side. Set a cookie with a unique ID, and on each new request, add the URL of the request to the (ordered) list of things as the request is made. This will of course require that you have the ability to read the cookie on every request and modify your logs. This wouldn't be too hard to do in mod_perl, which allows you to define handlers for each phase of the Apache request cycle. That's pretty involved though.

1 From RFC 2068, which lays out the HTTP 1.1 Protocol :
a browser client could have a toggle switch for browsing openly/anonymously, which would respectively enable/disable the sending of Referer and From information.

HTH.

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

In reply to Re: site statistics by arturo
in thread site statistics by Baz

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.