Permanent login does't work

Notice: This thread is very old.
Ajax
Member | 59
+
0
-

Hello!
I used sandbox and because I have only private part of system (only logged users can see pages), all presenters inherits from BaseSecuredPresenter:

	public function startup() {
		parent::startup();

		if (!$this->user->isLoggedIn() && $this->getName() !== "Sign" && $this->getAction() !== 'In') {
			$this->redirect("Sign:in");
		}
	}

SignPresenter is more or less from sandbox:

	public function signInFormSucceeded($form, $values)
	{
		if ($values->remember) {
			$this->getUser()->setExpiration('14 days', FALSE);
		} else {
			$this->getUser()->setExpiration('20 minutes', TRUE);
		}

		try {
			$this->getUser()->login($values->username, $values->password);
			$this->redirect('Viz:show');

		} catch (Nette\Security\AuthenticationException $e) {
			$form->addError($e->getMessage());
		}
	}

In config.neon is:

	session:
		expiration: 14 days

Problem is, that system kicks me out after more or less 30 minutes of inactivity. But ini_get('session.gc_maxlifetime') == 1209600, PHPSESSID cookie has expiration in 14 days and $this->user->getLogoutReason() == NULL. Working on Debian/apache on localhost.

Can someone tell me what I'm missing?

Thanks a lot!

Quinix
Member | 108
+
+9
-

Debian cleans default session folder by cron – http://serverfault.com/…g-phps-built – it deletes all session files older than maximal maxlifetime defined in some php.ini (apache, fpm, cli.. it uses maximal value found). But if the max lifetime is set in php script, this cron does not know about it.

I think that easiest solution is to set custom session folder for your Nette app.

Ajax
Member | 59
+
0
-

It worked! You're great! :)

For future readers, Add path to dir in config.neon:

session:
		expiration: 14 days
		savePath: %appDir%/../sessions

Thanks again!