How to capture values from referrer?
Is there a way to capture the value passed in the referrer? I need to capture that and do some searching.
Is there a way to capture the value passed in the referrer? I need to capture that and do some searching.
Carl,
I'm trying out the function you posted above and for some reason it's returning blank. Below is my code:
<cfhttp url="https://app.knowledgeowl.com/api/head/article.json" method="get" timeout="15">
<cfhttpparam type="url" name="_authbykey" value="56a7d8c123131c4058361789">
<cfhttpparam type="url" name="project_id" value="55c4ffd456131c527e7899fe6">
<!---<cfhttpparam type="url" name="url_hash" value="calendar">--->
<!--- Pass along any URL values. --->
<cfhttpparam type="url" name="url_hash" value="#queryStringGetVar(CGI.http_referer, 'slug')#" />
<cflog text="URL-Hash: #queryStringGetVar(CGI.http_referer, 'slug')#" type="Information" file="CGIparameters">
</cfhttp>
<cfscript>
/**
* Gets the value of a variable in a query string.
*
* @param query_string The query string to examine. (Required)
* @param this_var_name The variable to look for. (Required)
* @return Returns a string.
* @author Shawn Seley (shawnse@hotmail.com)
* @version 1, August 1, 2005
*/
function queryStringGetVar(querystring, this_var_name){
var re_found_struct = "";
querystring = trim(querystring);
re_found_struct = REFindNoCase("(^|[\?|&])#this_var_name#=([^\&]*)", querystring, 1, "true");
// = re_found_struct.len & re_found_struct.pos
if(arrayLen(re_found_struct.pos) gte 3) {
if (re_found_struct.pos[3] GT 0) return urlDecode(mid(querystring, re_found_struct.pos[3], re_found_struct.len[3]));
else return "";
} else return "";
}
</cfscript>
The log shows blank. So, I'm not quite sure why. The CGI.http_referrer shows this: https://devbox.mysite.com/kb/?slug=calendar
Okay, so all I have to do to get the URL parameter value is URL.variable name.
<cfhttp url="https://app.knowledgeowl.com/api/head/article.json" method="get" timeout="15">
<cfhttpparam type="url" name="_authbykey" value="56a7d8c532131c4058362589">
<cfhttpparam type="url" name="project_id" value="55c4ffd258561c527e294fe6">
<!---<cfhttpparam type="url" name="url_hash" value="calendar">--->
<!--- Pass along any URL values. --->
<cfhttpparam type="url" name="url_hash" value="#URL.slug#" />
<cflog text="URL-Hash: #URL.slug#" type="Information" file="CGIparameters">
</cfhttp>
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.