5 Replies Latest reply on May 23, 2006 2:22 AM by BKBK

    session trouble

    Leftbower Level 1
      I am setting up a shopping cart app and am running into some issues... in my Application.cfc, onSessionStart I am creating an object instance of User in the session:

      <cffunction name="onSessionStart" returnType="void" output="false">
      <cfset SESSION.user = createObject("component","User").init()>
      </cffunction>

      The User.cfc looks like this:

      <cfcomponent>
      <cffunction name="init" access="public" returntype="struct">
      <cfset var user = structNew()>
      <cfset user.userID="#createuuid()#">
      <cfset user.cart = createObject("component", "ShoppingCart").init()>
      <cfset user.info = createObject("component", "UserInfo").init()>
      <cfreturn user>
      </cffunction>
      </cfcomponent>

      The ShoppingCart.cfc starts like this:

      <cfcomponent output="false">
      <!--- Initialize the cart’s contents --->
      <cffunction name="init" access="public" output="false" returntype="ShoppingCart">
      <cfset VARIABLES.cart = ArrayNew(1)>
      <cfreturn this />
      </cffunction>
      ...

      and the UserInfo.cfc starts like this:

      <cfcomponent>
      <cffunction name="init" access="public" output="false" returntype="UserInfo">
      <cfset VARIABLES.info = StructNew()>
      <cfreturn this />
      </cffunction>
      ...

      Is this a proper way to set this up? I have gotten some intermitant session errors (e.g. "user.info.something is an undefined java...")

      Also - are there any issues/best practices that I ought to be aware of that could arise with customers using tabbed browsing or multiple browser instances?

      Thanks in advance!
      Andy