• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

session trouble

Community Beginner ,
May 21, 2006 May 21, 2006

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

534

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2006 May 21, 2006

Copy link to clipboard

Copied

Just a little addition

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 21, 2006 May 21, 2006

Copy link to clipboard

Copied

Thanks!

In a similar vein, I recently switched to using Jsession variables because I was concerned with unjudicious use of server memory when this goes live.

Interestingly, even when a tab is closed (or a new site is opened in the same tab) the session is still alive. It's not until the browser is closed and restarted that the session ends. Is that what is supposed to happen?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2006 May 21, 2006

Copy link to clipboard

Copied

Yes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 22, 2006 May 22, 2006

Copy link to clipboard

Copied

much appreciated.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2006 May 23, 2006

Copy link to clipboard

Copied

LATEST
!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation