How to get/set session life cycle?



360

Hello.

It depends on the session adapter you use (see: http://phalcon-php-framework-documentation.readthedocs.org/en/latest/api/Phalcon%5Session%5Adapter.html) You can implement your own session adapter and control the life cycle inside it.

Note, session.gc-maxlifetime won't work! (see: http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime) There is a good explanation here http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes

Please, describe here which session lifecycle you need and I will try to help



2.5k
edited May '15

The configuration of session in my project: public/index.php

...
$di->setShared('session', function() {
    $session = new Phalcon\Session\Adapter\Files();
    $session->start();
    return $session;
});
...

Could you please tell me what is the default life cycle of session when using the above configuration?

Do I have to implement a new session adapter? If it is necessary, could you please give me an example including the life cycle configuration?

Thanks!

Hello.

It depends on the session adapter you use (see: http://phalcon-php-framework-documentation.readthedocs.org/en/latest/api/Phalcon%5Session%5Adapter.html) You can implement your own session adapter and control the life cycle inside it.

Note, session.gc-maxlifetime won't work! (see: http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime) There is a good explanation here http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes

Please, describe here which session lifecycle you need and I will try to help

By default a session lasts 1440 seconds (24 minutes). You can modify that setting by either changing your php.ini file, or calling ini_set() with the appropriate parameters.



2.5k

As Denis said, session.gc-maxlifetime won't work.

By default a session lasts 1440 seconds (24 minutes). You can modify that setting by either changing your php.ini file, or calling ini_set() with the appropriate parameters.



2.5k

Could anyone help?

Please explain in more detail what you are referring to by "life cycle"



2.5k

I use session to store user login data. But it seems to be invalid after 3 or 4 hours. User had to re-login the system again. I want to set this time to be 12 hours.

Please explain in more detail what you are referring to by "life cycle"

+1 to this. Same problem here.