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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:57:37+00:00 2026-06-05T19:57:37+00:00

I am writing a small e-shop application with Symfony 2 and I need some

  • 0

I am writing a small e-shop application with Symfony 2 and I need some way to store the user’s shopping cart in a session. I think using a database is not a good idea.

The application will use entities like Product, Category, ShoppingCart where Product and Category are persisted into the database and users will be choosing products into their ShoppingCart.

I have found NativeSessionStorage class which is supposed to save an entity into a session. But there is no written process of implementation into an application.

Do I use this in the controller or in a separated class ShoppingCart? Could you give me a short example of NativeSessionStorage usage?

EDIT:
The question was not set correctly:

The goal is not to save all product ids into a cookie. The goal is to save only a reference for basket (filled with products) in application memory on server-side and assign proper basket to user. Is this even possible to do this in PHP?

EDIT2:

Is a better solution to use a service?

  • 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-05T19:57:39+00:00Added an answer on June 5, 2026 at 7:57 pm

    Don’t know if this way is the better way to store your data temporary. You can use this to instantiate a session object :

    $session = $this->get("session");

    Don’t forget the ‘use’ in your controller :

    use Symfony\Component\HttpFoundation\Session;
    

    Then, the session starts automatically when you want to set a variable like :

    $session->set("product name","computer");

    This is based on the use of the Session class, easy to understand. Commonly definitions :

    get(string $name, mixed $default = null)
    
    Returns an attribute.
        
    set(string $name, mixed $value)
    
    Sets an attribute.
    
    has(string $name)
    
    Checks if an attribute is defined.
    

    Also, take a look to the other ways to store your data : Multiple SessionStorage

    UPDATED LINK: Session usage: https://symfony.com/doc/current/session.html

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

Sidebar

Related Questions

I am writing small social application. One of the features is to write user
I'm writing a small Java app using JavaMail that sends the user an automated
I'm writing small application using OpenCV. Everything works great on my computer. I can
I'm writing a small program using CLR console application and when I write something
I'm writing small application for my Django project. The idea is to create some
I writing small application in pure C++. But now I encourage strange problem. I
I'm writing small utility app (JBoss Netty based) which should perform some trivial login
I have an application where I am reading and writing small blocks of data
I'm writing a small application in java I read text files in various sizes
I'm writing a small sudoku game/solver in Linux using python with TUI (not GUI,

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.