Skip to main content
Inspiring
May 28, 2010
Question

application.cfc <cfobject name="SESSION.myShoppingCart" component="ShoppingCart">

  • May 28, 2010
  • 1 reply
  • 756 views

Can anyone tell me why I'm getting this:

Element MYSHOPPINGCART is undefined in SESSION

I added this line to my application.cfc (in the onSessionStart section)

<cfobject name="SESSION.myShoppingCart" component="ShoppingCart">

To be sure , I ended the session and application by setting a timeout value of 0,0,0,0 but I'm still getting the above

The actual line of code triggering this error is in the addMerch.cfm page and is:

<cfinvoke component="#SESSION.myShoppingCart#" method="Add" merchid="#URL.addMerchID#">



This topic has been closed for replies.

1 reply

ilssac
Inspiring
May 28, 2010

Dax Trajero wrote:

<cfobject name="SESSION.myShoppingCart" component="ShoppingCart">

Try <cfset session.myShoppingCart = createObject("component","path.to.shoppingCart")>

I believe the createObject() function is the preferred method for component invocation amoung ColdFusion developers.  I've not used the <cfobject...> tag much and I am not sure of its ins and outs.

Inspiring
May 28, 2010

do I literally type in that whole line ? eg. will it understand "path.to.shoppingCart" ?

ilssac
Inspiring
May 28, 2010

Dax Trajero wrote:

do I literally type in that whole line ? eg. will it understand "path.to.shoppingCart" ?

No, you replace that with the an appropiate path either from the calling file to the CFC OR from a defined mapping to the CFC.  Replace the file path slashes (/ and \) with dots.

If the CFC is in the same directory as the calling file, it would just be the CFC file name without the CFC extension.

I.E. ("component","shoppingCart")

If the CFC is in a sub directory under the calling file named "myObjects".

I.E. ("component","myObjects.shoppingCart").

If you had a ColdFusion mapping named "myMapping" and inside that was a directory "BusLogic" with the CFC.

I.E. ("component","myMapping.BusLogic.shoppingCart")