Copy link to clipboard
Copied
How to get the HTTP command parameter in cfml?
e.g.
if the HTTP command is
GET /DATA/pg/index.cfm?lang=en HTTP/1.1
then the parameter should be
lang=en
if the HTTP command is
GET /DATA/pg/index.cfm?lang=fr HTTP/1.1
then the parameter should be
lang=fr
Try creating a file named "cgitest.cfm" with the content:
<cfoutput>#cgi.query_string#</cfoutput>
Browse to http://localhost/cgitest.cfm?lang=en (or substitute the appropriate path on your server).
The fact that HTTP_REFERER is populated makes me suspect that you have some redirection code, such as CFLOCATION, in your index.cfm file.
Copy link to clipboard
Copied
I think that cgi.query_string is what you're looking for.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7785.html
Copy link to clipboard
Copied
I put
<cfdump var="#cgi#">
<cfdump var="#http#">
<cfdump var="#url#">
in index.cfm.
HTTP_REFERER returns
/DATA/pg/index.cfm?action=edit
QUERY_STRING returns
action=edit
I do not see "lang=en" anywhere.
Copy link to clipboard
Copied
Try creating a file named "cgitest.cfm" with the content:
<cfoutput>#cgi.query_string#</cfoutput>
Browse to http://localhost/cgitest.cfm?lang=en (or substitute the appropriate path on your server).
The fact that HTTP_REFERER is populated makes me suspect that you have some redirection code, such as CFLOCATION, in your index.cfm file.
Copy link to clipboard
Copied
Yes, there is <cflocation> in index.cfm.
Although I put cfdump before <cflocation>, cfdump still display QUERY_STRING as
<cfdump var="#cgi#">
<cfdump var="#http#">
<cfdump var="#url#">
<cfif NOT IsDefined("action")>
<cfset action = "edit">
<cflocation url="index.cfm?action=#action#" addtoken="No">
<cfabort>
</cfif>
How to get the original parameter "lang=en"?
Do I still create the "cgitest.cfm" page?
My coldfusion version is 6.1.
Copy link to clipboard
Copied
Do one thing at a time.
Get rid of the cflocation until you know what is in your query string. Once you have it sorted out, create the necessary session variable and use that on your next page.
Copy link to clipboard
Copied
What is the session variable(s) look like?
Should it be stored in the index.cfm and/or the calling page?
Copy link to clipboard
Copied
I'm not sure I understand your question. Can you provide some more specific information about what your are trying to accomplish?
You might start by reviewing the CF documentation on session variables.
http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7fd4.html
Find more inspiration, events, and resources on the new Adobe Community
Explore Now