Jump to content

QUICK POLL: Cart data: keep in $_SESSION variable or stick in a table?


marmite

Recommended Posts

$_SESSION

 

the way i set mine up... was like this...

 

$_SESSION[cart][]=array(id=>'product id#',quanity=>'#',colours=>'red|white(for example)',special=>'text');

 

but thats just me...

 

then i have my functions to get all my other importants... weight, # in stock,etc...

well... all the product information comes from the database... and honestly... i REALLY wouldnt want to clean up a database after everybody for those of you out there who look at a page, add stuff to your cart, then close the window(you know who you are)...

 

but i keep all the non static stuff active in the $_SESSION[cart], so you know exactly what their getting...

 

product id -> so you know what they are getting... can access that product, so you have all the static stuff(price, weight, amount in stock, etc...)

quantity -> so you know how many their getting(if set to 0, removes from cart)

colours -> so you know what colour they want(depending on availability)

specials -> if they want any thing special done with the order

 

therefore... the only thing thats in there besides customary stuff... is `id`... which again, allows you to access the product, then apply their custom stuff :-)

Yes there are people out there who look at the Jaguar and Ferrari and don't continue the transaction. but if you have a field in the table completed Y/N you can periodicaly kill thiss off. Session A dog is for life. A session variable for 20 mins.

 

Desmond.

 

 

you can set sessions to last far longer then 20 min... i've left mine for days, and returned and it was still active... sessions are great, because your storing it on the server... and is near unhackable(if done right)...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.