Zend Framework - restored session identifier, cannot remain included in the system

Come on people :( is there anyone there who can help me here

Hi guys, I'm trying to store sessions in a database using Zend sessions, but for some time my sessions have been dying out. I am not sure if any code is being executed that does this or something else.

I noticed that the session id seems to be regenerating some time after logging in.

This is even though the following line has been added to the htaccess file:

php_value session.auto_start 0 

As a result, I log out every minute when I logged in.

Here is my code in my boot file

 $config = array( 'name' => 'session', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime' ); $saveHandler = new Zend_Session_SaveHandler_DbTable($config); Zend_Session::rememberMe($seconds = (60 * 60 * 24 * 30)); $saveHandler->setLifetime($seconds)->setOverrideLifetime(true); Zend_Session::setSaveHandler($saveHandler); //start your session! Zend_Session::start(); 

I do not use any other session-related functions, except possibly for Zend_Auth at login.


Infact rememberme calls the Session class ID regeneration function - the end result is that I constantly log out after a few minutes.

+6
source share
5 answers

I had this problem because the main identifier in my DB table was set to INT (11) (IDIOT!)

Duplicate DB sessions created when logging in to Zend_Auth

It must be set to CHAR (32)! I installed it out of habit. I spent 4 days tracking this.

+2
source

I think you might have this problem because you are calling rememberMe BEFORE the session starts.

You must start a session first, otherwise remember that you will not do anything, because you need to establish a session to set the memorization time.

rememberMe calls the restoreateId function, and restoring Id is what the session really needs.

Place the rememberMe call after the session starts, then see how it works for you.

If this is not the case, I do not know what could be, since my code is similar to yours.

+5
source

Have you tried something like this?

 protected function _initSession() { $config = array( 'name' => 'session', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime', 'lifetime' => 60*60*24*30, ); Zend_Session::setSaveHandler(new F_Session_SaveHandler_DbTable($config)); } 

Thus, the lifetime is not set after the initialization of the database sessions, but is directly included in the initialization parameters - it works for me, I see no reason why this might end in your case :).

+5
source

I think you need to look once at the following values ​​after the boot code

 session.gc_maxlifetime session.cookie_lifetime 
+2
source

If you are configuring session resources in the * .ini configuration file, check the resources.session.cookie_domain parameter. I spend 3 hours when I thought about it.

0
source

Source: https://habr.com/ru/post/887816/


All Articles