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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:38:35+00:00 2026-05-14T02:38:35+00:00

Is that a good practice to store the objects of the domain model in

  • 0

Is that a good practice to store the objects of the domain model in the PHP session ?

This would enable to avoid to query and reconstruct every PHP object to each PHP request.

Is there a size limit ?

  • 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-05-14T02:38:35+00:00Added an answer on May 14, 2026 at 2:38 am

    If you use OOP in PHP you probably want these objects to be reconstructed at every request for several reasons.
    All in all there wouldn’t be much of a performance difference between storing, loading and deserializing the objects from the session, as you suggested, or just reconstructing them either.

    It would depend much on the kind of the classes you use too, of course. Constructing a class usually isn’t very problematic in terms of performance unless there is a real lot of stuff needed to do so (Database queries, etc.)

    Additionally, doing so could make your code less understandable and/or maintainable too.

    And yes, there is a size limited defined by the maximum memory usage of PHP set in the php.ini

    So this question is not really answerable unless you exactly know what the classes you want to store in the session are, what they do and how they interact.

    For example, if you were having a class which abstracts a logged-in user on your site, storing it’s object in the PHP session would probably a good idea. In most other cases, however it wouldn’t.

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

Sidebar

Related Questions

Is it a good practise, to use the php session object, to store several
I understand that it is good practice to use a using block when getting
I heard Kevin Skoglund (lynda.com) say that it is good practice to get in
Is it a good practice to initialize columns that we can know their values
It says that if there is a virtual function, it is a good practice
I was just wondering if this approach looks like a good practice for apps
When using Django sessions , is it good practice to see if session data
I am not that good with encoding but I am even falling over with
Fact: I'm not that good with jQuery. Problem: I have a form containing dynamically
I'm not that good at debugging IE, because... well because I hate it and

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.