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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:10:18+00:00 2026-05-15T23:10:18+00:00

I work in a project which uses the session a lot. We have a

  • 0

I work in a project which uses the session a lot. We have a db handler (the standard one from Zend) and currently i have this initialization (db handler + session start) in a plugin for the preDispatchLoop. Previously it was in preDispatch but because of it being called for each action (included those in the ‘forwarded’ action, it caused me problems.

My problem is that i began working in internationalization and i began using the router to detect the language in the URI: we use the form /language/controller/action). The router would like to use the session to read/store the language. But as you may know the router comes first and then the (pre/post) dispatcher stuff.

So the question would be: why not move the session initialization to the bootstrapping ? it’s because it was there before but i had to move it because i need to test that the db (remember that the session uses the db) is accessible to prevent errors. And if there’s an error i simply redirect (request->setController/setAction error). If i move back the session initialization code to the bootstrapping i can’t make the redirect if the db is not accessible.

I’ve read other question and i’ve found many people asking to access the request object from the bootstrapping. But they all say: you can but shouldn’t. but then, how would i do in this case ? my last option would be to move back the sessions initialization to the bootstrapping and if it fails, manually send headers and read the view but the error code but that’s a horrible hack.

My thoughts are that the session shouldn’t be used that early. They shouldn’t be called in the bootstrapping as they’re not yet fully aware of the controller/action requested. I think that to get the language i could simply rely in cookies (manual) and get it from there (as well as from the URI). And if eventually some day the session info must be used in the bootstrapping i would use a global variable.

What do you think ? is there an error in the way i’m controlling the application ?

Some questions seen:

Zend Framework: Getting request object in bootstrap

Best way to deal with session handling in Zend Framework

(Zend version 1.9.6, not using Application nor Bootstrap)

  • 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-15T23:10:18+00:00Added an answer on May 15, 2026 at 11:10 pm

    I would move the session initialization and db connection to the bootstrapping.
    If you can’t connect to your db during bootstrapp this should count as low-level error. It is not excepted to happen in production.
    Simply wrap your bootstrapping process into a try catch block so you can output an error page.

    // in your index.php
    try {
        $application = new Zend_Application(
            APPLICATION_ENV,
            APPLICATION_PATH . '/configs/application.ini'
        );
    
        $application->bootstrap()
                    ->run();
    
    } catch (Exception $e) {
        header('Content-type: text/html; charset=utf-8');
        header('HTTP/1.1 503 Service Unavailable');
        header("Retry-After: 3600");
        // Output some error page.
        echo "<html><head><title>System Error</title></head><body>...</bod></html>";
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project which uses Apache Xmlbeans for databinding. Currently it is very
I recently had to struggle with one installation project (which uses most popular product
I work on a project that uses multiple open source Java libraries. When upgrades
I'm working on a project which uses user authentication. I'm facing a issue with
I am working on a project which uses an import #import progid:Blah.blah.retrieve rename_namespace(Blah) but
My current project is in rails 2.3.5 which uses restful authentication. I am moving
In project A, i have a static class which stores data for specific types,
I'm developing a project using a layered architecture. I have a DAL in which
I'm trying to work through Project Euler and I'm hitting a barrier on problem
I'm starting work on a project using Rails, but I'm waiting for the 3rd

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.