Session or cookies

J

Joseph Byrns

I have written a shopping cart type web application using session variables
to store the shopping cart details (with a timeout of 59 minutes).
Originally my timeout was set to the default 20 minute timeout, but I was
finding that people could take longer than 20 minutes between pages. So my
question is, what are peoples recommendations here, should I continue using
the session variables or should I adopt a cookie approach and store shopping
cart details locally, or something else completely different.

Thanks in advance.
 
M

Marina

It depends on your needs. If an hour timeout works for you, then that's
great.

The other good thing about cookies, is that even if users close the browser
and go back to the site later, whatever was in their shopping cart will
still be there.
 
J

Joseph Byrns

And do you find that an hour timeout is generally adequate for your
applications?

Thanks.
 
M

Marina

I think it really depends on the application. Sometimes session timeouts are
just unacceptable, and you need to find an alternate way.

I would say for a shopping cart, you really don't want session timeouts. I
know when I use online shopping apps, I would be annoyed if it kept timing
out for whatever reason.

Wrap all your user information access/retrieval code in some functions. That
way, if you ever decide to switch the way you store user information, you
only need to change the code inside those methods.
 
H

Hans Kesting

Joseph said:
I have written a shopping cart type web application using session variables
to store the shopping cart details (with a timeout of 59 minutes).
Originally my timeout was set to the default 20 minute timeout, but I was
finding that people could take longer than 20 minutes between pages. So my
question is, what are peoples recommendations here, should I continue using
the session variables or should I adopt a cookie approach and store shopping
cart details locally, or something else completely different.

Thanks in advance.

I don't think it's a good idea to store a whole shopping cart in cookies.
What you *can* do however is make your own "sessions": store just a
shopping cart ID in a cookie, and store the whole cart in the database
(under that same ID).
 
B

bruce barker

i agree, i expect my cart to last days. you should store the cart info in a
database with maybe a 30 day purge, and store the cart id in a cookie.

-- bruce (sqlwork.com)


| Joseph Byrns wrote:
| > I have written a shopping cart type web application using session
variables
| > to store the shopping cart details (with a timeout of 59 minutes).
| > Originally my timeout was set to the default 20 minute timeout, but I
was
| > finding that people could take longer than 20 minutes between pages. So
my
| > question is, what are peoples recommendations here, should I continue
using
| > the session variables or should I adopt a cookie approach and store
shopping
| > cart details locally, or something else completely different.
| >
| > Thanks in advance.
| >
| >
|
| I don't think it's a good idea to store a whole shopping cart in cookies.
| What you *can* do however is make your own "sessions": store just a
| shopping cart ID in a cookie, and store the whole cart in the database
| (under that same ID).
|
| --
| Hans Kesting
 
V

vMike

Joseph Byrns said:
I have written a shopping cart type web application using session variables
to store the shopping cart details (with a timeout of 59 minutes).
Originally my timeout was set to the default 20 minute timeout, but I was
finding that people could take longer than 20 minutes between pages. So my
question is, what are peoples recommendations here, should I continue using
the session variables or should I adopt a cookie approach and store shopping
cart details locally, or something else completely different.

Thanks in advance.
I have found the people come back the next day or so on some occasions. I
store a cart ID in a cookie and store the cart information in a database.
The cookie expires after so many days. I have had people come back after the
expiration and complain that someone took something out of their cart! You
do have handle price changes and out of stock merchandise though using this
method.
just my 2 cents
Mike
 
A

Alan Silver

You do have handle price changes and out of stock merchandise though
using this
method.

Not necessarily. The way I have done this is to have the cookie store
the basket ID, then the basket contents in a database. But ... the
basket contents in the database were basically only a list of product
IDs and quantities. That way if prices change, you don't have to worry
about it. When displaying the basket, you just show the product details
from the products table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top