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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

more session variables vs. table entry

Status
Not open for further replies.

Shilohcity

Technical User
Jul 12, 2000
136
GB
Hi there

I have read all sorts of opinions regarding the use of session variables vs. querystrings vs. database entry etc.
and was wondering if anybody had any tips for my situation.

I am in the process of building a shopping site and am planning to use a mix of hidden fields and database entry to manage the cart of the shoppers. The only problem I can forsee is that if the shopper enters more than one item it is forwarded as a string so if at a later date they wish to add further items and I use an "UPDATE itemorder WHERE "&orderid&" = orderid" it will overwrite the existing values with the new ones.

Maybe I should hold all the items, quantities etc as hidden fields? or maybe I should use a session variable.

Well feedback is appreciated on this especially as my hosting company has threatened to go through my code line by line to prevent server degradation at $100.00 an hour EEEEEEEKKKK!!

Cheers muchly

Justin.
 
Hey Justin what I would do is create a shopping cart table in my db to hold all the items. with each record in the shopping cart table associate the userid with it. what i mean by userid is have them before they access the sight create a login name and password. with that login name and password give them a userid. when a user goes back to the sight(at this point you should have a stored procedure to get all the items in the cart that relates to the userid to bring back to the form) have them log in. once they log in get there userid and and bring back all the items for the user. by doing it this way all the info gets stored in the db and does not put a strain on the web server. give it a shot...

Hope this helps

Frandazzo
 
Yeah I was considering this option but decided against requiring the users to login every time they wished to shop at the site. The client I am working for was also highly against this option as they saw it turning "browsers" away.

I agree with you about allocating userid's and am thinking maybe of allocating these when an order is "confirmed" and using a cookie to store it in the users browser. This still has the downside of being dependent on the user having cookies enabled.

I am still a little confused as to the maintaining of orders however, my confusion is this:

user selects items 1, 4 , 6 and orders 2, 6, 8 of each.
This is entered in table as a string itemid=1, 4, 6 and quantity=2, 6, 8.
If they then choose to order 4 of item 1 and I use an update query it will overwrite the current strings with itemid=1 and quantity=4

Any suggestions as to how to deal with this would be most appreciated.


Justin.X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top