Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variables?

Status
Not open for further replies.

DaveL

Programmer
Jun 8, 2000
40
US
I have a shopping cart checkout form with multiple image submit buttons on it including "update count", "calculate shipping" and "finalize order". My problem is... what is the best way to hold onto the checkout form values such as name, address, email address, etc., when the user executes one of the submit buttons that performs a function (such as updating an item count or calculating the shipping amount) and then returns to the checkout form for completion. If the user has already keyed in some or all of the form, when the program returns to the checkout form, the values the user has already keyed in should still be on the form. Is there an easier way to pass the form values from page to page other that putting every one of them in the URL variable list on the action page? Am I missing something?

Thanks!
 
Dave,

How about session variables? Those will work to hold values throughout the users' session, and you can kill them when the session ends. Calista :-X
Jedi Knight,
Champion of the Force
 
Thanks for the response Calista!

Over the last couple of days I have had to do much research. My conclusion was that session variables are the way to go for this problem. It seems to be working fine.

I am still working through a couple of issues, such as initialization (where is the best place to do it?) and locking of the session variables.

Thanks, Dave.
 
As far as initializing session variables, I would tend to do it on the page where I intended to collect the information. Maybe the user login screen to collect name, address, email, etc.? These things could also be stored in a cookie, but you will always have to deal with users that do not accept cookies. If you search this forum, you will find a lot of information about doing that. In my personal opinion, there's usually no one right way to do anything. You should do what seems logical for your application.

According to what I have read, session variable should be locked whenever they are read or written to. Calista :-X
Jedi Knight,
Champion of the Force
 
I agree with you on initialization of the variables. I will figure this out as I figure out how I want to organize the application.

As far as locking on the session variables, I am using cflock on all my updates to the session variables and I have automatic read locking set on in the Cold Fusion Administrator for session variables only.

Dave.
 
You can use a tables too (in case you use database).
There are lots of advantages, if the user times out, you can still recover his/her selections and all the good stuff. Using many session variables with many users could stress the cold fusion server. It depends how many users will access it at once.
You could also use XML structure and place it in a hidden and use submissions between pages or simply hiddens with submission.

But as Davel said, use what's logical to your application.
 
Sorry for jumping in unannounced (and uninvited!), but DaveL seems to be in the process of developing an e-commerce situation...

DaveL if you are developing within a virtual hosting environment that has a shared secure server, just remember to accomodate for the fact that variables will not be preserved across these separate domains....

Just a heads up...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top