• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 16. Case Study: Online Store > Allowing Customers to Shop

Allowing Customers to Shop

For customers to shop on an electronic commerce site, they need to be able to choose a product and then make a decision about whether to put the selected product into their shopping carts. In support of this capability, Listing 16.1 contains the code for an Application.cfm file for the site.

Listing 16.1. Application.cfm—Initializes the Shopping Cart for the Electronic Commerce Site

<!---

    Online Store Case Study

    This is the Application.cfm file for the online furniture store.
    It begins with a <cfapplication> tag that enables session
    management and extends the default session timeout to 30
    minutes.

--->

<cfapplication name="onlinestore" sessionmanagement="yes"
sessiontimeout="#CreateTimeSpan(0,0,30,0)#">

<!---

    Set the datasource name up as a variable

--->

<cfset dsn = "furniture">

<!---

    Set up the shopping cart if it is not already done.
    The Session.arrProducts array tracks the ProductsID values
    of the products the shopper is purchasing. The
    Session.arrQuantities array tracks the corresponding
    quantities of each product.

    Note that the Session scope has to be locked throughout
    the online store application to avoid possible memory
    corruption!

--->

<cfif not isDefined("Session.arrProducts")>

    <cflock scope="session" type="exclusive" timeout="5">

        <cfset Session.arrProducts = ArrayNew(1)>

    </cflock>

</cfif>

<cfif not isDefined("Session.arrQuantities")>

    <cflock scope="session" type="exclusive" timeout="5">

        <cfset Session.arrQuantities = ArrayNew(1)>

    </cflock>

</cfif>


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint