1

I am storing a google review URL in my database as:

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair%2Bbrick%2Bnj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd=0x89c18348735c2907:0x59aa614832a36b22,3,

And then in my application I set that URL to a variable and I redirect the user to that URL using cflocation.

<cfquery name="geturl" datasource="#datasource#">
select (residential_ReviewURL) as redirectURL
from subscribers
</cfquery>

<!--- Redirect to main html redirect page --->
<cfoutput>
<cflocation url="#getURL.redirectURL#">
</cfoutput>

However the URL gets changed at some point because I think that Coldfusion doesn't like the characters in the URL and it replaces them with % or removes them. Therefore when the user hits the google page, the page doesn't process as it should.

Here is how the URL looks after the redirect:

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair%2Bbrick%2Bnj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd%3D0x89c18348735c2907%3A0x59aa614832a36b22%2C3%2C

How can I stop ColdFusion from changing the URL and keep id exactly as how it is stored in the database?

UPDATE

So I found that URLdecode will preserve the string. Here is what I have.

#urlDecode(getURL.redirectURL)#

The output is as follows

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair+brick+nj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd=0x89c18348735c2907:0x59aa614832a36b22,3,

Why is it adding CFID and CFTOKEN to the URL though? I have it turned off in my Application.CFM:

<cfapplication name="yaya" 
    clientmanagement="no" 
    sessionmanagement="no" 
    setclientcookies="no" 
    setdomaincookies="no"
    sessiontimeout="#CreateTimeSpan(0,2,0,0)#" 
    applicationtimeout="#CreateTimeSpan(1,0,0,0)#"
      >
Brian Fleishman
  • 1,237
  • 3
  • 21
  • 43
  • 3
    regarding the cfid and cftoken, have you tried adding addToken="no" to the cflocation? – luke Mar 14 '17 at 13:54
  • Yes I have, but it doesn't seem to matter. But also, jsut outputting the URL to the screen shows the CFID and CFTOKEN in there. – Brian Fleishman Mar 14 '17 at 13:56
  • @luke is correct, you have to specify `addToken="no"` to the cflocation tag in order for it to NOT append that to the URL. If it is still in the URL after doing that then check your database contents `getURL.redirectURL` for it in there. – Miguel-F Mar 14 '17 at 14:16
  • Even if I just output the URL to the screen, it shows the CFID and CFTOKEN, so that eliminates the cflocation aspect. I have confirmed that it is being stored in my DB without those tokens as well. Another thing I noticed is that if I pass the URL from the database in a URL variable, it adds it to that as well. – Brian Fleishman Mar 14 '17 at 14:24
  • 1
    The url you are displaying in your question has a cfid and cftoken. – Dan Bracuk Mar 14 '17 at 16:24
  • What happens if you remove the line `sessiontimeout="#CreateTimeSpan(0,2,0,0)#"` from your Application.cfm file? It should not be required since you have specified to not use session management. This is also assuming that you have enabled "per application settings" in your ColdFusion administrator. – Miguel-F Mar 14 '17 at 18:16
  • @DanBracuk - Yes you're right, been staring at this screen too long and totally missed that. Thanks. All is good. – Brian Fleishman Mar 14 '17 at 18:45
  • 1
    You should write up your solution so that others can see how this was fixed. – James A Mohler Oct 11 '18 at 16:40

1 Answers1

0

To help others coming here:

cflocation have a parameter addToken which needs to set to no if we do not want to add CFID and CFTOKEN to the generated URL.

Adobe CFML reference: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-j-l/cflocation.html

Binod Kalathil
  • 1,939
  • 1
  • 30
  • 43