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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:37:06+00:00 2026-05-22T20:37:06+00:00

i am using Zend_Session_SaveHandler_DbTable to store the session in a table my profiler tells

  • 0

i am using Zend_Session_SaveHandler_DbTable to store the session in a table

my profiler tells me that on each page request zend does:

# Query Time

(1) connect 0.0032038688659668

(2) DESCRIBE session 0.0041539669036865

(3) SELECT session.* FROM session WHERE (((session.session_id = ‘7nnan8ltd6h64sigs6dlkicvh0’ AND session.save_path = ” AND session.name = ‘PHPSESSID’))) 0.00057697296142578

Total time : 0.008 sec

when i do queries on other tables, zend DESCRIBEs them once(the first time it access that table), then if i refresh the page it only does the query with no Describe, on the session table it does DESCRIBE on every page (since i use authentication … )

how can i cache only the metadata on the session table?

i am currently using this

class Gestionale_Application_Resource_Cache extends Zend_Application_Resource_ResourceAbstract{
public function init ()
{
    $options = $this->getOptions();

    // Get a Zend_Cache_Core object

    //valori che vengono presi dal file di configurazione
    $cache = Zend_Cache::factory(
        $options['frontEnd'],
        $options['backEnd'],
        $options['frontEndOptions'],
        $options['backEndOptions']);
    Zend_Registry::set('cache', $cache);

    Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);//per mettere in cache la meta-info
    return $cache;
}

this is my config file

...
;cache stuff
resources.cache.frontEnd = core 
resources.cache.backEnd = file 
resources.cache.frontEndOptions.lifetime = 1200 ; in secondi
resources.cache.frontEndOptions.automatic_serialization = true 
resources.cache.backEndOptions.lifetime = 3600 ; in secondi
resources.cache.backEndOptions.cache_dir = APPLICATION_PATH "/../cache"
pluginPaths.Gestionale_Application_Resource = APPLICATION_PATH "/../library/Gestionale/Application/Resource"  
;;fine cache stuff

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.db.params.charset = "utf8"
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "gestionale"
resources.db.isDefaultTableAdapter = true
autoloaderNamespaces[] = "Gestionale_";serve per caricare il plugin di sotto quando si usa anche ZFdebug
resources.frontController.plugins.acl = "Gestionale_Controller_Plugin_Acl"
resources.db.params.profiler = true
...

this is my session table

CREATE TABLE IF NOT EXISTS `session` (
  `session_id` char(32) NOT NULL,
  `save_path` varchar(32) NOT NULL,
  `name` varchar(32) NOT NULL DEFAULT '',
  `modified` int(11) DEFAULT NULL,
  `lifetime` int(11) DEFAULT NULL,
  `session_data` text,
  PRIMARY KEY (`session_id`,`save_path`,`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

thanks 😀

  • 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-22T20:37:07+00:00Added an answer on May 22, 2026 at 8:37 pm

    Wherever you are initializing the session save handler, either in the bootstrap or the config file, make sure that you call Zend_Db_Table_Abstract::setDefaultMetadataCache() first.

    To specify it in your config file, put the session config after the ;;fine cache stuff line:

    ...
    ;cache stuff
    resources.cache.frontEnd = core 
    resources.cache.backEnd = file 
    resources.cache.frontEndOptions.lifetime = 1200 ; in secondi
    resources.cache.frontEndOptions.automatic_serialization = true 
    resources.cache.backEndOptions.lifetime = 3600 ; in secondi
    resources.cache.backEndOptions.cache_dir = APPLICATION_PATH "/../cache"
    pluginPaths.Gestionale_Application_Resource = APPLICATION_PATH "/../library/Gestionale/Application/Resource"  
    ;;fine cache stuff
    
    resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
    resources.session.saveHandler.options.name = "session"
    resources.session.saveHandler.options.primary[] = "session_id"
    resources.session.saveHandler.options.primary[] = "save_path"
    resources.session.saveHandler.options.primary[] = "name"
    resources.session.saveHandler.options.primaryAssignment[] = "sessionId"
    resources.session.saveHandler.options.primaryAssignment[] = "sessionSavePath"
    resources.session.saveHandler.options.primaryAssignment[] = "sessionName"
    resources.session.saveHandler.options.modifiedColumn = "modified"
    resources.session.saveHandler.options.dataColumn = "session_data"
    resources.session.saveHandler.options.lifetimeColumn = "lifetime"
    
    resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
    resources.db.params.charset = "utf8"
    ...
    

    Or, if you don’t want to rely on their order in the config file, you can add an _initSession() method to your bootstrap class that specifically loads them in the correct order:

    protected function _initSession()
    {
        $this->bootstrap('cache');
        $this->bootstrap('session');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I am using Zend Framework and Zend_Session to do global session management for
Looking for an example of storing session data in a database, using the Zend
I am using Zend Cache with page caching but it seems to miss the
I store a couple of value in a temporary session using: $job = new
I'm using zend mail extended with zend_mail_storage_imap and I built an application that looks
I'm teaching myself Zend am and having a problem with using my session to
I'm trying to get the user's timezone on their first request using Zend Framework.
I am using the Zend Framework but my question is broadly about sessions /
Using Zend Framework, I've created a Model to insert a record into a database.
I am using Zend Framework(MVC part of it), and need to either redirect user

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.