View Full Version : pseudo add to cart with coldfusion

10-06-2002, 01:06 PM
On a result page i have listing the matching 'albums' it basically outputs a few things for each result (each matching album)

-link to detail page
-add to cart link

this is a fake little project just for learning and the add to cart button does not yet do anything but i would like it to.

How can i make it so that when that 'add to cart' link is clicked a session / cookie is set containing that particular albumname or albumid.

Then later after you when you go to the fake checkout page the albums you previously 'added to cart' are listed.


It is after all just fake and for playing with, i figure there is a simple way to do it right?

on the checkout page all i have to do is something like:

SELECT albumName artistName etc
FROM tables
WHERE albumID = '#session.albumid#' ?

the question here is wether i use a session (dont know much about it) and how to get it to set the session when i click add to cart?

10-07-2002, 02:29 PM
i'm not sure i completely undersand your problem.

i think it comes down to this : you want to store some data (an ID for the selected albums) somewhere, without writing it to a database + you want to retrieve the ID and use them as selectioncriteria to build the checkoutpage.

How to do it depends on your app, the used language, servercapacity, etc.

I use a lot of ASP lately, and I would store the ID's in session-variables.

How ?
- create/modify your global.asa (each time a user starts the application, a session for this user is created and space is reserved for the session-variables. )
- create/modify your session_on start sub like this
Sub Session_OnStart


-when an album is selected, post the form to an ASP page where you store the ID in the sessionvariables like this


- to retrieve the ifno and use it in a selectquery:

sql="SELECT albumName artistName etc FROM tables WHERE albumID = anID"

If the user needs to be aible to order more then one album, you can use a string variable and create a 'comma separated string' by adding the ID's each time an album was chosen (+ create an array with it and then use a loop for the select-querys)

Or you could use multiple session-variables (ad them to the global.asa)


and store each ID in a new variable + keep track of the numer of albums ordered (to know witch session-variable to use to write the next album ID. probably best with a "select case" structure.)

Does this makes any sense to you ?

10-08-2002, 11:09 PM
what is 'global.asa' ? is it a asp file or something? sort of like coldfusions application.cfm for specifying global app settings and variables.

well i think it makes sense :) but i am still a bit of a newbie especially to CF so i don't fully understand. you are correct in terms of understanding what i'm trying to do though. perhaps i'll take it one bit at a time starting with the application file settings (i'm assumung that's what you mean by 'global.asa')

/ goes off to read up on CF application / session variable syntax

10-09-2002, 09:20 AM

you'll find more info about the global.asa at the folliwing adresses:




for some other sites my search engine came up with

10-15-2002, 03:32 AM
It sounds like he's using ColdFusion (not ASP), but it also sounds like he's on the right track. ;)

04-09-2003, 12:30 AM
<cfset session.YourVariable = YourValue>

thats it

But if your not using cfmx lock your session vars !! <cflock>