You should also check to make sure the key exists in the cookie jar before
attempting to read it.

<cfif StructKeyExists(COOKIE,"appname_#pagename#")>
   --read cookie or run some code--
<cfelse>
   --redirect or run some other code--
</cfif>



On Fri, May 23, 2008 at 9:44 AM, Mark Ireland <[EMAIL PROTECTED]>
wrote:

> You should never do this:
> <cfset cookieVal = #COOKIE.cname#>
>
> When in doubt rely on <cfdump val="#cookie#">
>
>
>
> > To: [email protected]
> > Subject: [cfaussie] Re: variable name confusion
> > Date: Fri, 23 May 2008 14:52:22 +1000
> > From: [EMAIL PROTECTED]
>
> >
> >
> > <cfset cookieVal = #COOKIE.cname#>
> >
> > Should be
> >
> > <cfset cookieVal = "#COOKIE.cname#">
> >
> >
> >
> > Andrew Scott
> > Senior Coldfusion Developer
> > Aegeon Pty. Ltd.
> > www.aegeon.com.au
> > Phone: +613  9015 8628
> > Mobile: 0404 998 273
> >
> >
> >
> >
> > -----Original Message-----
> > From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf
> > Of nedlud
> > Sent: Friday, 23 May 2008 1:40 PM
> > To: cfaussie
> > Subject: [cfaussie] variable name confusion
> >
> >
> > I have an app that gets included on three seperate pages withing the
> > same domain (pages A, B, C all use app X). On each page where it gets
> > used, I use a cookie to store user preferences. The preferences need
> > to be unique to where the app gets used, so I dynamicly create the
> > cookie name depending on which page it gets loaded from (page As
> > cookie is called cookie A, page Bs cookie is called cookie B, etc)
> >
> > The following code seems to work for naming and setting the cookies...
> >
> > <cfset cname="appname_" & "pagename">
> > <cfcookie expires="never" name="#cname#" value="#fvalue#">
> >
> > My trouble starts when I'm trying to read the value of the cookie on
> > the next visit.
> >
> > <cfset cookieVal = #COOKIE.cname#>
> >
> > This isn't working since it's loking for a cookie with the liiteral
> > name of "cname" instead of the value of "cname".
> >
> > How do I resolve this?
> >
> >
> >
> > >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to