1. It is a bug. I was setting the "expires=" attribute by calling a
function which returned an integer. This was what caused it to fail.
When I replaced this with a hard coded integer, or I changed the
function to return a date, the cookie is set fine. See code at bottom.

I'm using Mach-II - I have a session initialiser in my main listener
which is called at the beginning of a new event. This is where I set the
cfcookie if one doesn't already exist. If you think I shouldn't set the
cookie here, where should I do it?

2. Yeah I wondered about that. I'll change the name.

Thanks, Douglas

PS Here's the code that failed:

<cfset sessionID = CreateUUID() />
<cfcookie name="sessionID" value="#sessionID#" expires="#ExpiryDays()#"
/>

And here's the code which works:

<cfset sessionID = CreateUUID() />
<cfset expiryDate =
DateFormat(DateAdd("d",ExpiryDays(),Now()),"dd/mm/yy")/>
<cfcookie name="sessionID" value="#sessionID#" expires="#expiryDate#" />
                                

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dawson, Michael
Sent: 17 May 2004 15:00
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] CFCOOKIE in CFC/Shopping carts

1. Sounds like a bug, but also sounds like a design issue waiting to
happen.  It would not be a good practice to set cookies, or other
external variables, for that matter in a component.  Regardless, can you
show us come code?

2. I think I would choose a different cookie name.  "sessionid" is
already used in the Session scope and "jsessionid" is used in the cookie
scope, if you have J2EE session management enabled.  It might end up
being quite confusing.

-----Original Message-----
From: Douglas Humphris [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 17, 2004 8:33 AM
To: [EMAIL PROTECTED]
Subject: [CFCDev] CFCOOKIE in CFC/Shopping carts

Can anyone offer some advice on either of the following:

1. I've got this problem where I try to set a cookie in my cfc component
and it doesn't actually create the cookie on the client (but it does
appear in the cookie scope during the request). But if I set the same
cookie in the cfm page it does create the cookie on the client and also
adds it to the cookie scope.

2. Basically, I want to find some way of persisting shopping carts so
that users can come back and find their carts as they left them. My
current model is to store all cart data in the database, and store a
UUID into a cookie called sessionID. Then, if the session is new, I'll
look for the cookie. If cookie.sessionID is defined, I will retrieve the
cart data from the database and add it to the session.manager.
Otherwise, I'll add an empty cart to the session.manager.

Many thanks,

Douglas

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool,
Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to