For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > February 2006 > shoping cart issue with cookies









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author shoping cart issue with cookies
surfunbear@yahoo.com

2006-02-13, 6:55 pm


I am working on designing a website for a friend which will allow the
user to
select jewlery items, add them to a shopping cart, and at some later
time
they can proceed to checkout. I am designing this using an object
oriented/polymorphic
approach so I can more easily adapt this work I am doing twards any
website development
to sell some other type of items. The perl/CGI scripts would generate
HTML
based on the contents of an SQL database and other settings in config
files.


I am planning on using cookies, though I realize there are other
approaches like hidden fields. Anyway, if I set an expiration date on
the cookie, is that guaranteed to work right ?
The users browser determines when it has expired. What if their
computer had the wrong date ? Perhaps some users would prefer their
cookie not expire.

I downloaded mysql and connected to it fine with Perl. When the user
adds an item to
the cart, it should create an entry in the shopping cart SQL table. The
inventory table will have the price and number of available items of
each item. It's possible that between the time the user adds an item to
their shopping cart and then proceeds to checkout that the item will no
longer be available or it's price may have changed. Particularly this
depends on how long
a cookie can last. The cookie id would be stored in the shopping cart
table. I can
display a message if an item has changed price or is no longer
available at the time of checkout.

I have quite a bit of Perl experience, but I am just getting into CGI.
I downloaded the sambar
server and have it running locally on my PC.

I seem to recall all kinds of different approaches to this when I was
brainstorming last w,
if anyone has any comments or ideas, please post a reply, thanks

Paul Lalli

2006-02-13, 6:55 pm

surfunbear@yahoo.com wrote:
> I am working on designing a website for a friend which will allow the
> user to
> select jewlery items, add them to a shopping cart, and at some later
> time
> they can proceed to checkout.


There are MANY different applications already written and debugged
which accomplish your stated goal. How is your wheel intended to be
different from all the other already invented wheels?

> I am planning on using cookies, though I realize there are other
> approaches like hidden fields. Anyway, if I set an expiration date on
> the cookie, is that guaranteed to work right ?


"Guaranteed"? Of course not. Nothing stops me from writing a browse
that ignores cookies, or ignores the expiration date of cookies. That
is at the control of the user, as it should be.

> The users browser determines when it has expired. What if their
> computer had the wrong date?


*Most* of the time, you set cookies' expiration dates with relative
dates (ie, "five months from now") not absoulute dates (ie, July 13,
2006).

> Perhaps some users would prefer their cookie not expire.


Then you include a "remember my login on this computer" option, like
hundreds of thousands of websites already do. If that operation is
selected, you change the expiration date.

> if anyone has any comments or ideas, please post a reply, thanks


Check out the hundreds of programs that have already been written that
do this already. Chances are large that they're better developed,
debugged, and maintained than anything you yourself are going to create
on the fly.

Paul Lalli

surfunbear@yahoo.com

2006-02-13, 6:55 pm

I saw Akopia Interchange, which was based on the older perl minivend
shopping cart but it requires linux and I don't have that. I'm looking
into how to install it, but not sure if it's worth it on my old PC. I
am just trying to help someone else out.

It seems working with windows Activestate perl as I have been has
fewer options and I need to start thinking about linux at some point.

kin

2006-02-22, 3:55 am


u can use cookies ..as for my view it doesnt matter wheather the
user has wrong date on his machine, as cookies will be destroyed as the
time you mention like after 4 hours or after 5 hours ..as u wish, So if
the user has wrong time then the calculation will be based on user's
time. And it also good to use hidden fileds. they r very usefull

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com