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 8488351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:30:36+00:00 2026-06-10T21:30:36+00:00

I am developing a Shopping cart application and I am needing help about storing

  • 0

I am developing a Shopping cart application and I am needing help about storing cart items using $_SESSION.

The Concept

When user clicks on Add to Cart, the following information is stored: Product ID e.g. 5312, Product Name, Product Quantity, Product Rules (e.g. color : white, size : medium and so on)

The problem

The problem is that when I save the entry in $_SESSION by item ID. I want to assume the following:

  • User adds 1 item of product #11 which color is white
  • User then adds 2 items of product #11 which color is blue

If I save by item ID, the info will be overridden always, I want to make each call / each add to cart unique because I am assuming he may add different sizes, different colors of the same product.

How can I come over such a problem?

Any ideas or inputs are greatly appreciated.

  • 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-10T21:30:39+00:00Added an answer on June 10, 2026 at 9:30 pm

    You can do a multidimensional array with your SESSION variable.

    $_SESSION['cart']=array(
        $product_id=>array($product_count,$product_options),
        $product_id=>array($product_count,$product_options),
    );
    

    Or if the $product_id isn’t unique:

    $_SESSION['cart']=array(
        array($product_id,$product_count,$product_options),
        array($product_id,$product_count,$product_options),
    );
    

    With something like this, you can have a unique product id as the array key, then store the count, options, and other info you need.

    Another option would be to create a table for your shopping cart, and then have the session store the cart ID. Then you would simply check the mysql table for your cart info.

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

Sidebar

Related Questions

We are developing a shopping cart application. For every single user session i have
I am developing an app with a shopping cart. When I add a product,
PHP newbie here. I'm currently developing a shopping cart web site using PHP and
In developing a shopping cart application I've found that I needed to save settings
I'm developing a shopping cart system for a client using Joomla! 1.5 and VirtueMart
I'm developing a java EE web app using JSF with a shopping cart style
I am developing a shopping cart application for Restaurants in Android 2.1 . I
I am developing a custom shopping cart for which existing customers will need to
While developing an application using gwt in ecliplse crashed. Now the server is running
I'm taxed with developing a custom e-commerce application for my company (using PHP/MySQL). The

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.