I have a CGI script which is being called from many different pages. I need the CGI script to determine which page just called it. This was asked in the chatterbox earlier and it was said to be impossible; HTTP is stateless. But I won't accept impossible, somewhere, somehow someone has an idea of a workaround for this *crosses fingers*. Say we are at www.mypage.com/page1.shtml . We are including the CGI script as an SSI. The CGI has to output the full URL of page1.shtml. ( www.url.com/page.shtml )

Just for the sake of it, I also used

<!--#exec cgi="../cgi-bin/stats/downloads.pl"-->
My first idea was using $ENV{"HTTP_REFERER"}. I thought this worked at first but it turns out it only works if the page1.shtml is called directly. This is to say, if you are on www.mypage.com/page2.shtml and click a link to www.mypage.com/page1.shtml the CGI included on page1.shtml will say the referer was "www.mypage.com/page2.shtml" and NOT page1.shtml which it should!

I have used both the SSI and the exec cgi code and using HTTP_REFERER but it's absolutely not working. Can someone tell me how I can get the URL of the page that called it?

I could always pass param values of the URL to the script itself, that would work and I do realize that. The problem is this will be going on hundreds of pages and that's a lot of configuration time involved just to setup each param. If there's some HTTP echo command that can be passed to the CGI, that would probably work beautifully. I KNOW JS can do this, but I'm opposed to using JS all over the site.

Thank you wise monks, yet again.



"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

sulfericacid

In reply to Recalling the URL of initiating page by sulfericacid

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.