This is a known "feature".  You cannot set a cookie and then cflocation in
the same template.  You need to use an alternate method of sending the user
on to where you want them.

--K

-----Original Message-----
From: Paul Johnston [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 13, 2000 9:42 AM
To: CF-Talk
Subject: Wierd CFLOCATION error


An email is sent out with a url on it.  THe url sets a cookie and then
redirects the user with a cflocation tag.

For some reason, the cflocation tag is run before the cfcookie tag is
complete thus not allowing the cookie to be set.

Any ideas?

Paul

PS Code:

<CFQUERY NAME="getnextpage" DATASOURCE="mydsn">
SELECT
        refid,
        formrefid,
        nextpage,
    campaignenddate
FROM
        qb_referral
WHERE
        refid='#URL.refid#'
</CFQUERY>


<CFIF getnextpage.RecordCount GT 0>
    <!--- set cookie (if it already exists it doesn't matter) --->
    <!--- set it to "CID<ID of campaign>" and equal to 1 --->
    <!--- we only need to check if it exists on the order pages --->
    <cfif getnextpage.campaignenddate eq "">
        <cfset enddate = Now()>
    <cfelse>
        <Cfset enddate = getnextpage.campaignenddate>
    </cfif>
    <cfset days_to_end = DateDiff("d",Now(),enddate)>
    <cfif days_to_end eq 0><Cfset days_to_end = 1></cfif>
    <!-- set cookie -->
    <cfcookie name="CID#getnextpage.refid#" value="1"
expires="#days_to_end#">
    <!-- check if cookie exists -->
    <cfif NOT IsDefined("cookie.CID#getnextpage.refid#")>
        <cflocation url="referralerror.cfm?refid=#URL.refid#">
    </cfif>
    <!--- <cfoutput>#Evaluate("cookie.CID" &
getnextpage.refid)#</cfoutput> --->
    <!-- set relevant things up -->
    <CFSET refid=getnextpage.refid>
    <CFSET formrefid=getnextpage.formrefid>
<CFELSE>
        <!-- ERROR: refid parameter not found -->
    <!--- if the cookie doesn't exist, send the refid in the URL --->
    <cflocation url="order.cfm">
</CFIF>

<CFIF getnextpage.RecordCount GT 0>
    <html><head>
    <meta http-equiv="Refresh"
content="0;url=http://www.blurgh.co.uk<cfoutput>#REReplace(CGI.SCRIPT_NAME,"
referral.cfm","","all")#</cfoutput>order.cfm">
    </head><body>
    <cfoutput>If this page doesn't redirect you <a
href="#getnextpage.nextpage#">click here</a></cfoutput>
    </body></html>
<!--- for some reason this needs to be here --->
    <cfabort>
    <cflocation url="#getnextpage.nextpage#">
</cfif>


----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to