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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:09:57+00:00 2026-06-15T08:09:57+00:00

I use Zend_Auth to authenticate users and then store their details in the default

  • 0

I use Zend_Auth to authenticate users and then store their details in the default Zend_Auth session. This means that when a user edits his details, these changes won’t be reflected in the application until he re-authenticates.

I want to avoid this problem as so:

  1. When the user logs in we only store his user ID in a Zend_Auth session
  2. On each request we fetch the user’s details from the database in a preDispatch() hook, using the user ID which was stored upon login in the Zend_Auth session:

    class Plugin_Auth extends Zend_Controller_Plugin_Abstract
    {
    
        public function preDispatch(Zend_Controller_Request_Abstract $request)
        {
            if ($auth->hasIdentity())
            {
                $id = $auth->getIdentity()->id;
    
                $userModel = new Model_User();
    
                $user = $userModel->fetchOne($id);
    
                // Where do I store this user object ???
            }
    
        }
    }
    
  3. The problem is: where do i store this User object? I think we shouldn’t use sessions for this, since the goal of sessions is to persist data. There’s no need for persistence though, since we re-fetch the data from the database on each request. Only the user ID must be persistent. Would storing the User object in Zend_Registry be an option here?

  • 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-15T08:09:59+00:00Added an answer on June 15, 2026 at 8:09 am

    Use Zend_Session_Namespace to store the object. It can be as temporary or permanent as you wish to make it.

    Zend_Auth already uses this in the background as it’s default storage mechanism using the namespace of Zend_Auth.

    class Plugin_Auth extends Zend_Controller_Plugin_Abstract
    {
        public function preDispatch(Zend_Controller_Request_Abstract $request)
        {
            $session = new Zend_Session_Namespace('user');//instantiate session namespace
            if ($auth->hasIdentity())
            {
                $id = $auth->getIdentity()->id;
    
                $userModel = new Model_User();
    
                $user = $userModel->fetchOne($id);
    
                $session->user = $user;//store the object can be recalled anywhere
            }
        }
    }
    

    Of course Zend_Registry will work as well and as always the choice is yours. You may even find it appropriate to build this functionality into your auth adapter.

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

Sidebar

Related Questions

I use Zend_Auth and Zend_Auth_Adapter_DbTable in my project. I want to get a Zend_Db_Table_Row
I have a Zend Framework project using version 1.10.8 with Doctrine 1.2.4.I use Zend_Auth
In our project we use Zend Framework Model generator, which produces something like this
I use Zend framework with doctrine for a project , the problem is that
its possible to do a $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); but i thought
On this site I have a situation where a user might need to be
I want to know how to use PHP session variable in zend framework here
Let me begin by saying this; I know that similar questions exist, but they
I am using Zend_Auth_Adapter_Ldap to authenticate users for my Zend Framework based intranet website.
Zend_Auth provides an API for authentication and includes concrete authentication adapters for common use

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.