Potrzebuję pomocy w ustawieniu SESJI w ZENDA FRAMEWORK. Od razu zaznaczam, że walcze z tym problemem już trzeci dzień. Problem polega na tym, że sesje działają bez problemu na serwerze lokalnym, natomiast po wgraniu projektu na serwer produkcyjny, wystakuje mi błąd zamieszcozny poniżej:
Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'session has already been started by session.auto-start or session_start()' in /var/www/vhosts/{server_name}/subdomains/test/httpdocs/library/Zend/Session.php:451 Stack trace: #0 /var/www/vhosts/{server_name}/subdomains/test/httpdocs/library/Zend/Session/Namespace.php(143): Zend_Session::start(true) #1 /var/www/vhosts/{server_name}/subdomains/test/httpdocs/application/controllers/IndexController.php(82): Zend_Session_Namespace->__construct('session') #2 /var/www/vhosts/{server_name}/subdomains/test/httpdocs/library/Zend/Controller/Action.php(516): IndexController->articlesAction() #3 /var/www/vhosts/{server_name}/subdomains/test/httpdocs/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch('articlesAction') #4 /var/www/vhosts/{server_name}/subdomains/test/httpdocs/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Cont in /var/www/vhosts/{server_name}/subdomains/test/httpdocs/library/Zend/Session.php on line 451
Od razu podkreslam, że nigdzie w projekcie nie wywołuje funkcji session_start().
Mój kontroler wyglada następująco.
class IndexController extends Zend_Controller_Action { /** * @var Zend_Session_Namespace */ protected $_db_table_class = 'Application_Model_DbTable_Article'; protected $_form_class = 'Application_Form_Browser'; protected $_session; public function init() { $this->view->baseUrl = $this->_request->getBaseUrl(); Zend_Loader::loadClass('Zend_Db_Table'); Zend_Loader::loadClass('Zend_Session'); Zend_Loader::loadClass('Zend_Session_Namespace'); } public function indexAction() { ... } public function articlesAction() { $this->view->title = "Artykuły"; $getPage = $this->_getParam('page'); $this->_session = new Zend_Session_Namespace('session'); Zend_Session::regenerateId(); $this->_session->initialized = true; } ... }
Problem widzi na linijki
$this->_session = new Zend_Session_Namespace('session');
Plik z klasą bootstrap:
<?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { protected function _initAutoload() { 'namespace' => 'Default_', )); return $autoloader; } protected function _initDoctype() { $this->bootstrap('view'); $view = $this->getResource('view'); $view->setEncoding('UTF-8'); $view->doctype('XHTML1_STRICT'); } protected function _initDb() { 'host' =>'####', 'username' => '####', 'password' => '####', 'dbname' => '####', 'charset' => 'utf8' )); Zend_Db_Table_Abstract::setDefaultAdapter($db); } protected function _initSession() { $this->bootstrap('db'); 'name' => 'session', 'primary' => 'session_id', 'modifiedColumn' => 'modified', 'dataColumn' => 'session_data', 'lifetimeColumn' => 'lifetime' ); $saveHandler = new Zend_Session_SaveHandler_DbTable($sessionConfig); Zend_Session::setSaveHandler($saveHandler); } }
Problemu nawet nie rozwiązuje umieszczenie w kodzie bootstrap'a metody Zend_Session::start();
Plik kofiguracyjny application.ini:
[production] ... db.adapter = "pdo_mysql" db.config.host = "####" db.config.username = "####" db.config.password = "####" db.config.dbname = "####" db.config.charset = "utf8" db.isDefaultTableAdapter = true phpSettings.session.auto_start = 0 phpSettings.session.gc_probability = 0 phpSettings.session.gc_divisor = 0 resources.session.save_handler = user resources.session.save_path = APPLICATION_PATH "/../data/session" resources.session.use_only_cookies = true resources.session.remember_me_seconds = 864000 resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable" resources.session.saveHandler.options.name = "session" resources.session.saveHandler.options.primary.save_path = "save_path" resources.session.saveHandler.options.primary.name = "name" resources.session.saveHandler.options.primaryAssignment.sessionId = "sessionId" resources.session.saveHandler.options.primaryAssignment.sessionSavePath = "sessionSavePath" resources.session.saveHandler.options.primaryAssignment.sessionName = "sessionName" resources.session.saveHandler.options.modifiedColumn = "modified" resources.session.saveHandler.options.dataColumn = "session_data" resources.session.saveHandler.options.lifetimeColumn = "lifetime" ...
Zauważyłem, że po wywołaniu funkcji phpinfo() wartości dla session.save_handler (ustawiona na file) oraz dla session.save_path są różnie niz ustawione w pliku konfiguracyjnym. Pytanie czy to w ogóle ma znaczenie?
Bardzo prosze o pomoc, już naprawdę nie wiem, co robie nie tak.
Pozdrawiam