4 Replies Latest reply on Aug 25, 2007 1:23 AM by BKBK

    Can I write to CGI variables?

    silstorm
      My guess is that this isn't possible, but figured it was worth clarifying anyway.

      I have a page with a simple cflocation on it that sends the user to an external page. I need to somehow strip the referrer, mainly so that the site the visitor ends up on can't grab the search phrases in my url.

      The ideal way of doing this would be to remove the referring url before executing the cflocation tag, however obviously cflocation won't execute after a cfflush. Therefore, my idea was to use a cfset on cgi.http_referrer and set it as blank before executing cflocation.

      Assuming I can't write to CGI variables, are there any other methods that would work?
        • 1. Re: Can I write to CGI variables?
          Dan Bracuk Level 5
          use javascript window.location instead of cflocation.
          • 2. Re: Can I write to CGI variables?
            silstorm Level 1
            Thanks Dan (I sometimes think you must live on these forums, you're always first to answer my questions!)

            I have tried using the javascript method, however it seems to cause problems with some of the other systems (i.e some third-party callers don't execute the javascript), so I was hoping for a cf-based method if possible.
            • 3. Re: Can I write to CGI variables?
              Level 7
              CGI variables are strictly read-only and can't be modified at all.

              If you can't use window.location = '< http://www.newlocation.com>';,
              you could try a redirector using a META redirect:

              <meta http-equiv="refresh"
              content="<2;url=http://webdesign.about.com>">

              I'm not sure what the CGI variables will do, though, so you should try
              redirecting to your own page and cfdumping the cgi scope...

              Laterz,
              J

              In article <facgd1$2na$1@forums.macromedia.com>
              "silstorm"<webforumsuser@macromedia.com> wrote:
              > My guess is that this isn't possible, but figured it was worth
              > clarifying anyway.

              > I have a page with a simple cflocation on it that sends the user to
              > an external page. I need to somehow strip the referrer, mainly so
              > that the site the visitor ends up on can't grab the search phrases in
              > my url.

              > The ideal way of doing this would be to remove the referring url
              > before executing the cflocation tag, however obviously cflocation
              > won't execute after a cfflush. Therefore, my idea was to use a cfset
              > on cgi.http_referrer and set it as blank before executing cflocation.

              > Assuming I can't write to CGI variables, are there any other
              > methods that would work?


              --
              I'm trying a new usenet client for Mac, Nemo OS X.
              You can download it at http://www.malcom-mac.com/nemo

              • 4. Re: Can I write to CGI variables?
                BKBK Adobe Community Professional & MVP
                Silstorm,
                I think you really have nothing to worry about. What you seek is already there. It is actually the default CGI behaviour.

                By definition, CGI.HTTP_REFERER is the URL of the page that sent the browser to the current page. Therefore, the variable CGI.HTTP_REFERER will only be populated if a visitor arrives at the page by means of a link of one kind or another. That is, by means of an ordinary link, a redirection, a form submission and so on. The variable CGI.HTTP_REFERER will be blank if the visitor arrives at the page by other means, such as by cflocation.

                However, suppose that page1.cfm contains a link to page2.cfm and page2.cfm contains a cflocation to page3.cfm. Then the value of CGI.HTTP_REFERER at page3 will be the URL of page1.cfm, not that of page2.cfm. Test it yourself. Open page1.cfm, and then page2.cfm.

                page1.cfm
                ==========
                <a href="page2.cfm">to page2.cfm</a>

                page2.cfm
                ==========
                <cflocation url="page3.cfm">

                page3.cfm
                ==========
                referrer: <cfoutput>#cgi.http_referer#</cfoutput>