123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- <?php
- use Symfony\Component\HttpFoundation\Session\Session;
- use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
- class ChamiloSession extends System\Session
- {
- const NAME = 'ch_sid';
-
- public static function instance()
- {
- static $result = null;
- if (empty($result)) {
- $result = new ChamiloSession();
- }
- return $result;
- }
-
- public static function session_lifetime()
- {
- global $_configuration;
- return $_configuration['session_lifetime'];
- }
-
- public static function start($already_installed = true)
- {
-
-
-
- ini_set('session.use_only_cookies', 1);
-
-
-
- ini_set('session.cookie_httponly', 1);
-
-
-
-
-
- ini_set('session.use_trans_sid', 0);
- session_name(self::NAME);
- session_start();
- $session = self::instance();
- if ($already_installed) {
- if (!isset($session['checkChamiloURL'])) {
- $session['checkChamiloURL'] = api_get_path(WEB_PATH);
- } elseif ($session['checkChamiloURL'] != api_get_path(WEB_PATH)) {
- self::clear();
- }
- }
-
-
-
- if ($session->has('starttime') && $session->is_expired()) {
- $session->destroy();
- } else {
-
- $session->write('starttime', time());
- }
- }
-
- public function start_time()
- {
- return self::read('starttime');
- }
-
- public function end_time()
- {
- $start_time = $this->start_time();
- $lifetime = self::session_lifetime();
- return $start_time + $lifetime;
- }
-
- public function is_expired()
- {
- return $this->end_time() < time();
- }
- }
|