On 1/27/01, sebastian palmigiani penned:
>I have following code in application.cfm:
>
><cfif NOT IsDefined("COOKIE.cfid") OR NOT IsDefined("COOKIE.cftoken")>
>
><cfinclude template="NoCookie.cfm">
>
><cfabort>
>
></cfif>
>
>I have cookies turned off and no matter what page I am on this code is not
>picking up the fact that these 2 cookies don't exist. Yet when I make up a
>fictitious cookie name and test for it's existence then this code works.
>
>What is going on here?
>
>Sebastian
When a cookie is set, it exists at that point in time, even if the
user's browser doesn't accept it. So, if you have
setclientcookies="yes" in your cfapplication tag, then cookie.cfid
and cookie.cftoken will exist every time a page loads.
Try it. Put <cfcookie name="test" value="1" expires="1">
<cfoutput>#cookie.test#</cfoutput>
cookie.test will return 1 even if cookies are off.
Here is the code I use, which will try and set a cookie on entering
the site, then look for it on the first click. Keep in mind that you
will need to pass the cfid and cftoken in a query string for the 2nd
click, or CF won't KNOW it's the second click if cookies are off.
This code is based on client variables, but can be changed easy
enough for session variables. You could then set just before the last
</cfif> tag:
<cfset nocookie = 1>
Then where you want to include your nocookie.cfm page:
<cfif isdefined('nocookie')>
<cfinclude template="NoCookie.cfm">
</cfif>
Remember, this isn't going to work until first click and you will
need to make any links look like this to pass along cfid and cftoken
on the first click:
link.cfm?#variables.id#
<cfapplication name="myapplication"
clientmanagement="Yes"
sessionmanagement="No"
setclientcookies="Yes">
<CFIF not isDefined('client.initialize_session')>
<cfset client.initialize_session = now()>
<cfelse>
<cfset app_timeout = now() - createtimespan(0,0,20,0)>
<CFIF client.initialize_session GTE app_timeout>
<cfset client.initialize_session = now()>
<CFELSE>
<cfset clientlist = GetClientVariablesList()>
<cfloop index="i" list="#clientlist#">
<cfset temp = DeleteClientVariable('#i#')>
</cfloop>
<cfset client.initialize_session = now()>
</CFIF>
</CFIF>
<CFIF not isdefined('client.rollcount')><cfset client.rollcount = "1">
<cfcookie name="testcookie" value = "test" expires="1">
<cfset variables.ID = "cfid=#client.cfid#&cftoken=#client.cftoken#"><cfelse>
<cfset variables.ID = "#IIf(not isDefined('cookie.mycookie'), DE
('cfid=#client.cfid#&cftoken=#client.cftoken#'), DE(''))#">
</CFIF>
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists