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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:48:32+00:00 2026-06-10T07:48:32+00:00

I am building a model in Zend to build an object with key data,

  • 0

I am building a model in Zend to build an object with key data, which will be lazyloaded as required and stored in a session variable.

I am considering the singleton pattern, but find some of the material unclear on the cons. The singleton appears to persist and act like a global. But in a HTTP environment (unless it is stored in a session or database) would presumably only last as long as the request.

I want to authenticate the user, store the userid etc in private variables and as the current user acesses information i.e. current address store that as well to save database calls.

Am I right that the singleton only lasts as long as the session and that each subsequent user could make a singleton for themselves?

Thoughts on pros and cons 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-10T07:48:34+00:00Added an answer on June 10, 2026 at 7:48 am

    Your question is not really clear but a Singleton would disappear between each request, it’s just a kind (pattern) of class, if you do nothing to preserve it between calls to your server it will disappear.

    The cons around singletons are it often reflects a bad design : singletons are bringing stuff static. But a good OOP design is suppose to keep things private and modular, thus it should have very few coupling between classes. If many classes are used everywhere, then you might have something wrong.

    TMHO if you have one or two singletons in your app to maintain a global request context and a user context, that’s fine. If you have ten of them, you might need to redesign some parts of your app.

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

Sidebar

Related Questions

I am currently building my Core Data model, which I would like to sync
Im building an app that will use a Core Data model. I pretty new
I'm building a data model using ADO.NET Entity Framework 3.5 in Visual Studio 2008
I am building an MVC 3 application which uses the standard Model validation attributes
I'm building a gui component that has a tree-based data model (e.g. folder structure
I am building an application that will have a model that belongs_to another model
I'm building a webapp using the Zend Framework , and I need to model
I'm building the data model of my app and basically, for a given user,
I am building an application in Zend Framework. My model is made up of
I'm building a Zend-based Web app that will permit third-party extensions. Essentially, this application's

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.