Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > alt.php.sql > #25

sessions vs cookies for ecommerce cart in php

X-Received by 2002:a37:9a4a:: with SMTP id c71mr9957058qke.258.1564817686059; Sat, 03 Aug 2019 00:34:46 -0700 (PDT)
X-Received by 2002:ad4:55a9:: with SMTP id f9mr101042063qvx.133.1564817685745; Sat, 03 Aug 2019 00:34:45 -0700 (PDT)
Path csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!b26no8022652qtq.0!news-out.google.com!a5ni992qtd.0!nntp.google.com!b26no8022641qtq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups alt.php.sql
Date Sat, 3 Aug 2019 00:34:45 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=77.99.118.125; posting-account=QZBudAoAAACrR1qahi4VTSHm1PUWXEop
NNTP-Posting-Host 77.99.118.125
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <effca0bd-e8da-485b-a653-3293395596fa@googlegroups.com> (permalink)
Subject sessions vs cookies for ecommerce cart in php
From johnbon9999@gmail.com
Injection-Date Sat, 03 Aug 2019 07:34:46 +0000
Content-Type text/plain; charset="UTF-8"
Lines 30
Xref csiph.com alt.php.sql:25

Show key headers only | View raw



I have an ecommerce shop online using php, sql, javascript,ajax and sessions.

I have both guest and members cart options at checkout.

Everything works fine.

I store my cart items in a session currently.

Users can log in or have a guest cart.

Guests cart userids are referenced by the current session id.

members can login and their carts are referenced by their usersids from the database.

The problem is, the session expires after a certain amount of time and so the cart items are lost and the user has to start again.

On doing some research I have found that after the user logs in, I can store his user id in a cookie and I can specify how long that cookie lasts for which is ideal!

I am thinking of changing the code so that I store the items added to the cart in my database tables and simply reference them with the user id ive stored in his cookie.

That way He can shop for ages and not lose his cart and I can send abandon cart emails etc...

I think this would work well as nearly every website uses cookies so people have to have them enabled in their browser these days. I could show a warning message if cookies arent enabled anyway..

What does everyone think about this?

Please note I am not seeking security advice here.

I havent implemented this as yet - Im really looking to see if I can set my session lifetime to last a few hours/days instead.

Back to alt.php.sql | Previous | NextNext in thread | Find similar


Thread

sessions vs cookies for ecommerce cart in php johnbon9999@gmail.com - 2019-08-03 00:34 -0700
  Re: sessions vs cookies for ecommerce cart in php "J.O. Aho" <user@example.net> - 2019-08-17 23:52 +0200

csiph-web