Skip to content
Snippets Groups Projects
Commit 46ec499c authored by PavelBegunkov's avatar PavelBegunkov
Browse files

mad session

parent a8a999a4
Branches
Tags
No related merge requests found
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Handler_Session extends Controller_Handler {
protected $_session;
public function before() {
$this->setAccessLevel(self::ACCESS_USER);
$this->setAccessLevel(self::ACCESS_ANYBODY);
parent::before();
$this->_session = Session::instance();
}
public function action_getSessionTime() {
$session = Session::instance();
if ($session->get('LoggedIn')) {
$dif_time = $session->get('dif_time');
if (User::instance()->isSignedIn() && $this->_session) {
$dif_time = $this->_session->get('dif_time');
$timeout = User::SESSION_LIFETIME;
$remain = $timeout - $dif_time;
if ($remain <= 0) {
$this->completeSignOut();
}
$session->set('last_time',
$session->get('last_time') - $dif_time);
$this->_session->set('last_time',
$this->_session->get('last_time') - $dif_time);
} else {
$remain = 0;
}
......@@ -25,8 +25,8 @@ class Controller_Handler_Session extends Controller_Handler {
}
public function action_closeSession() {
if ($session->get('LoggedIn')) {
$this->completeSignOut();
if (User::instance()->isSignedIn()) {
User::instance()->completeSignOut();
}
$this->response->body(json_encode(0));
}
......
......@@ -8,7 +8,7 @@ class Kohana_User implements ArrayAccess {
protected $_model;
protected $_userInfo;
const SESSION_LIFETIME = 600; //seconds
const SESSION_LIFETIME = 20; //seconds
/**
* Вовзращает экземпляр класса (singleton-паттерн)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment