Session array

how to add values in a session array

Page 1 of 1

1 Replies - 8339 Views - Last Post: 01 September 2005 - 07:11 PM Rate Topic: -----

#1 parthiban  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 21-August 05

Session array

Posted 31 August 2005 - 04:42 AM

hi when i execute the below code, the current product that i clicked is displayed in shopcart page. the previous product didn;t showed in the product . plz help.





<cfif isDefined('AddToCart')>
<cfif not isDefined('Session.cart')>
<cfset thisitem = structnew()>
<cfset Session.cart = arrayAppend(Session.cart,thisitem)>
</cfif>
<cfif not isDefined('Session.cart.isbn')>
<cfset session.cart.isbn = arraynew(1)>
</cfif>
<cfif not isDefined('Session.cart.isbn')>
<cfset session.cart.qty = arraynew(1)>
</cfif>
<cfif not ListFind(ArrayToList(Session.cart.isbn),url.isbn)>
<cfset thisproduct = ArrayLen(Session.cart.isbn) + 1>
<cfset Session.cart.isbn[thisproduct] = url.isbn>
<cfset Session.cart.qty[thisproduct] = 1>
<cfelse>
<cfset thisproduct = ArrayLen(Session.cart.isbn) + 1>
<cfset Session.cart.isbn[thisproduct] = url.isbn>
<cfset Session.cart.qty[thisproduct] = 1>
</cfif>
</cfif>

Is This A Good Question/Topic? 0
  • +

Replies To: Session array

#2 supernova333  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 590
  • Joined: 12-March 02

Re: Session array

Posted 01 September 2005 - 07:11 PM

I saw you had another thead about session variables not saving their value (or something like that). Make sure you have session variables enabled with a <cfapplication> tag (normally in your application.cfm). I don't see any problems with that code but a lot depends on what else your shopping cart application is doing.

<cfapplication name="yourApp" sessionmanagement="yes">

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1