Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:38:15+00:00 2026-06-11T18:38:15+00:00

On an e-commerce site with no username/login to persist cart data, would it be

  • 0

On an e-commerce site with no username/login to persist cart data, would it be better to use the PHP $_SESSION variable or a browser cookie to persist items in the shopping cart? I am leaning toward $_SESSION since cookies can be disabled, but would like to hear thoughts from you.

Thank you in advance for your consideration.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:38:16+00:00Added an answer on June 11, 2026 at 6:38 pm

    Neither

    No large sites would dare store a user’s cart in a session or cookie – that data is just to valuable.

    What customers are buying, when they select items, how many they purchase, why they don’t finish the checkout, etc.. are all very, very important to your business.

    Use a database table to store this information and then link it to the user’s session. That way you don’t lose the information and you can go back and build statistics based on users carts or solve problems with your checkout process.

    Log everything you can.

    Database Schema

    Below is a simplified example of how this might look at the database level.

    user {
        id
        email
    }
    
    product {
        id
        name
        price
    }
    
    cart {
        id
        product_id
        user_id
        quantity
        timestamp    (when was it created?)
        expired      (is this cart still active?)
    }
    

    You might also want to split the cart table out into more tables so you can track revisions to the cart.

    Sessions

    Normal PHP Sessions consist of two parts

    1. The data (stored in a file on the server)
    2. A unique identifier given to the user agent (browser)

    Therefore, it’s not $_SESSION vs $_COOKIE – it’s $_SESSION + $_COOKIE = “session”. However, there are ways you can modify this by using a single encrypted cookie which contains the data (and therefore you don’t need an identifier to find the data). Another common approach is to store the data in memcached or a database instead of the filesystem so that multiple servers can access it.

    What @Travesty3 is saying is that you can have two cookies – one for the session, and another that is either a “keep me logged in” cookie (which exists longer than the session cookie), or a copy of the data inside separate cookie.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an e-commerce site which sells PC components using PHP and
I am just learning the ropes of php and am building an e-commerce site
I am currently creating a custom e-commerce site (in php, but that's not really
I'm trying to use a script that is provided by an E-commerce site that
I am developing an e-commerce site for use in the UK, and have been
I'm working with an e-commerce site that is heavily data-driven and dynamically generated, so
I'm trying to build an e-commerce site. Which technology should I use for the
I have a PHP/MySQL e-commerce site that is placing order detail information into a
Has anyone tried to build an e-commerce site atop MS Dynamics, using the new
I am working an e-commerce site which will allow pdfs to be downloaded once

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.