CFLib.org – Common Function Library Project

stripURLToken(x)

Last updated February 24, 2009

author

David Grant

Version: 1 | Requires: CF5 | Library: StrLib

Description:
Supply a string and the string is returned with the URL token removed (cfid=2322&cftoken=1243934978). ? or & is accounted for, as well as any combination of upper/lower case text. Useful when you just want the URL and simple parameters, excluding session information. Updated: Jason Bartholme added jsession variables

Return Values:
Returns a string.

Example:

<cfscript>
thisAddress = cgi.script_name & "?" & cgi.query_string;
thisAddress = stripURLToken(variables.thisAddress);
</cfscript>

<!--- session info will be stripped off --->
<cfoutput>#variables.thisAddress#</cfoutput>

Parameters:

Name Description Required
x String to modify. Yes

Full UDF Source:

/**
 * Strips the cfid/cftoken information from a string.
 * Updated: Jason Bartholme
 * added jsession variables
 * 
 * @param x      String to modify. (Required)
 * @return Returns a string. 
 * @author David Grant (x@seizethedave.com) 
 * @version 1, February 23, 2009 
 */
function stripURLToken (x) {
return REReplace(x, "(\?|&)([Cc][Ff][Ii][Dd]|[Cc][Ff][Tt][Oo][Kk][Ee][Nn]|[Jj][Ss][Ee][Ss][Ss][Ii][Oo][Nn][Ii][Dd])=[\s\S]+", "", "ALL");
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson