Forum Moderators: coopster

Message Too Old, No Replies

PHP Cookies tutorial

to create an almost full ecommerce site

         

le_gber

8:31 am on Oct 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi all,

I was wondering if someone could point me to a good offline or online (I would prefer offline though) resource to get the gripps on dealing with cookies (both persistent and seesion based) to create an online application for one of my customer.

It will have almost the same capabilities than a ecommerce site, i.e. adding products and quatity to basket, retrieving basket info, retrieving past order info (for a short time i.e. a week or so), saving current basket for 24 hours and submitting order.

The diff with ecommerce site is that this would be for members and I would manage the product list so no need for fancy backend capabilities.

Thanks in advance.

Leo

Adrian2k4

3:42 pm on Oct 5, 2004 (gmt 0)

10+ Year Member



so what exactly do you need cookies for?

le_gber

8:02 pm on Oct 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



well I thought I would hold the info in there as if it was a shopping basket.

Do you think I sould get the info in a db?

Cheeers,

Leo

Adrian2k4

8:21 pm on Oct 5, 2004 (gmt 0)

10+ Year Member



in my opinion you should save information in a db whenever possible.
you can't be sure that the browser accepts cookies, so you should only use them for features not crutial to the site's functionality. (i.e. automatic login function - "remembering the user")

regards
adrian

le_gber

10:01 am on Oct 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Adrian2k4

Nobody else uses cookies for shopping cart purposes? Is every one using a DB?

Leo

jamie

7:26 pm on Oct 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi le_gber,

we use cookies in our shop - the cookie holds the session id (32-digit random string). we then store all their choices (shopping basket) in a table in the database which i access using the COOKIE['sessionid'].

i think sessions are the best way of making sure as many people as possible can use the shop, 'cos if a cookie can't be set, then the session id is appended to each URL and passed in that way from page to page, so that the customer can be tracked through the shop. however because of our structure we can't use sessions - so a cookie is fine.

we also have a P3P privacy policy on the site, which helps with IE6 privacy issues

i'd still look into using tables to store the shopping basket - the cookie stores the session id which is used as the db table key

hth

ergophobe

4:43 pm on Oct 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't know of a cookie tutorial offhand, but you might try looking through some of the resources in this thread from the Forum Library

[webmasterworld.com...]

More to the point, however, you will also find some good resources to get you started with a database both in that thread and in the Forum Library in general.

I would have to agree that you don't want to depend on cookies for storing actualy shopping cart information. You want that in a DB, with the cookie just remembering that the user in question has an active shopping cart. If the user has cookies disabled or a cookie blocker or just clears the cookie cache, all information will disappear. If the cookie merely holds an id to the user and cart, that information is still there. If the user has signed up with a username and password, you can still retrieve the cart for users who have cookies disabled or who have lost the cookie.

Tom

le_gber

7:55 pm on Oct 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In fact I was thinking of using cookies because the number of people that will have access to this section of the site will be minimal. It won't be a ecommerce shopping site but rather a back end ordering system where suppliers can order products, ie: -

- the number of people using it will be very limited (in the hundred(s))
- we can force them to have cookies enabled if they want to use this facility

I wanted to use cookies because I was thinking of allowing them to view and/or print past order for 7 days (easily done by setting a cookie expiry date) but they won't be allowed to modify them for now on.

I am just not sure how to do it.

Thanks for your help.

Leo