OK..here goes...not makin any claims...but this works fine for the site it's
on.

The site has an index.cfm file which uses a varaiable (pg) to include the
appropriate content (pretty simple template framework).

CODE AT TOP OF INDEX.CFM FILE (not in Application.cfm):

<!--- test for existence of the test cookie to ensure cookies are
enabled--->
<cfif NOT IsDefined("Cookie.CookieTest") AND NOT
IsDefined("URL.StopCookieTest")>
  <cfinclude template="cookie_test.cfm">
  <!--- the abort is only needed if the user is sent to the disabled cookie
notification page --->
  <cfif NOT Len(CGI.HTTP_Cookie) OR IsDefined("URL.StopCookieTest")>
    <cfabort>
  </cfif>
</cfif>

CODE FOR COOKIE_TEST.CFM (pass yer own URL vars):

<!--- test for existence of the test cookie --->
<cfif NOT IsDefined("Cookie.CookieTest")>
  <!--- set test cookie --->
  <cfcookie name="CookieTest" value="1">
  <!--- redirect to second cookie test page to verify cookie was set --->
  <cfoutput>
    <cfheader name="location"
value="cookie_test2.cfm?pg=#pg#&lang=#lang#&tid=#tid#">
    <cfheader statuscode="302" statustext="Moved temporarily">
  </cfoutput>
</cfif>

CODE FOR COOKIE_TEST2.cfm (again use yer own URL vars):

<!--- Cookies are not enabled --->
<cfif NOT Len(CGI.HTTP_Cookie)>
  <cflocation
url="index.cfm?pg=cookie_test_disabled&lang=#lang#&tid=#tid#&StopCookieTest=
1">
<cfelse>
  <cflocation
url="index.cfm?pg=#pg#&lang=#lang#&tid=#tid#&StopCookieTest=1">
</cfif>


A few things to note:
1) This must run BEFORE any other cookies are set or the
Len(CGI.HTTP_Cookie) above will get fouled
2) For us this runs so fast that you don't even see it happen
3) You need to make your own cookie_test_disabled file outside of this test
to tell the user what to do if cookies are disabled ;-)

HTH

Cheers

Bryan Stevenson B.Comm.
VP & Director of E-Commerce Development
Electric Edge Systems Group Inc.
t. 250.920.8830
e. [EMAIL PROTECTED]

---------------------------------------------------------
Macromedia Associate Partner
www.macromedia.com
---------------------------------------------------------
Vancouver Island ColdFusion Users Group
Founder & Director
www.cfug-vancouverisland.com
----- Original Message -----
From: "Bryan Stevenson" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, July 23, 2003 1:28 PM
Subject: Re: cookie detection


> just remember it won't work if the user has disabled JS ;-)
>
> I have code to do a 2 page method that the user will never see and it
works
> regardless of JS being on....I'll try and dig it up.  It may only work
with
> the arhitecture of the site it's used on...not sure...but you can have it.
>
> Cheers
>
> Bryan Stevenson B.Comm.
> VP & Director of E-Commerce Development
> Electric Edge Systems Group Inc.
> t. 250.920.8830
> e. [EMAIL PROTECTED]
>
> ---------------------------------------------------------
> Macromedia Associate Partner
> www.macromedia.com
> ---------------------------------------------------------
> Vancouver Island ColdFusion Users Group
> Founder & Director
> www.cfug-vancouverisland.com
> ----- Original Message -----
> From: "Gabriel Robichaud" <[EMAIL PROTECTED]>
> To: "CF-Talk" <[EMAIL PROTECTED]>
> Sent: Wednesday, July 23, 2003 1:05 PM
> Subject: Re: cookie detection
>
>
> > hey jon,
> >
> > Thanks for the suggestion, i will more than likely use this idea!
> >
> > Gabriel
> >
> > jon hall wrote:
> > > Using CF alone as mentioned requires two pages, but you can do it with
> > > javascript in one. Depending on how your entrance page is set up, you
> > > could write out the hrefs with js or something similar so the cookie
> > > detection looks transparent to the user, and more importantly, to
> > > search engines.
> > >
> > > pseudocode...
> > >
> > > setCookie("someVal", "cookiename");
> > > if(getCookie("cookiename"))
> > >    //user has cookies
> > > else
> > >    //no cookies
> > >
> > > Good JS cookie library here which includes supportsCookies()...
> > > http://www.dithered.com/javascript/cookies/usage.html
> > >
> >
> >
> > --
> > Gabriel Robichaud
> > Programmer
> > Development & Alumni Relations Services
> > McGill University
> > (514)398-5653
> > [EMAIL PROTECTED]
> >
> >
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to