• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can I write to CGI variables?

Guest
Aug 20, 2007 Aug 20, 2007

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

505

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 20, 2007 Aug 20, 2007

Copy link to clipboard

Copied

use javascript window.location instead of cflocation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2007 Aug 20, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 23, 2007 Aug 23, 2007

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 25, 2007 Aug 25, 2007

Copy link to clipboard

Copied

LATEST
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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation