|
|
@ -84,6 +84,8 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private $_opened = false; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Starts the session. |
|
|
|
* Starts the session. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -92,10 +94,12 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co |
|
|
|
// this is available in PHP 5.4.0+ |
|
|
|
// this is available in PHP 5.4.0+ |
|
|
|
if (function_exists('session_status')) { |
|
|
|
if (function_exists('session_status')) { |
|
|
|
if (session_status() == PHP_SESSION_ACTIVE) { |
|
|
|
if (session_status() == PHP_SESSION_ACTIVE) { |
|
|
|
|
|
|
|
$this->_opened = true; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->_opened) { |
|
|
|
if ($this->getUseCustomStorage()) { |
|
|
|
if ($this->getUseCustomStorage()) { |
|
|
|
@session_set_save_handler( |
|
|
|
@session_set_save_handler( |
|
|
|
array($this, 'openSession'), |
|
|
|
array($this, 'openSession'), |
|
|
@ -110,19 +114,23 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co |
|
|
|
@session_start(); |
|
|
|
@session_start(); |
|
|
|
|
|
|
|
|
|
|
|
if (session_id() == '') { |
|
|
|
if (session_id() == '') { |
|
|
|
|
|
|
|
$this->_opened = false; |
|
|
|
$error = error_get_last(); |
|
|
|
$error = error_get_last(); |
|
|
|
$message = isset($error['message']) ? $error['message'] : 'Failed to start session.'; |
|
|
|
$message = isset($error['message']) ? $error['message'] : 'Failed to start session.'; |
|
|
|
Yii::error($message, __CLASS__); |
|
|
|
Yii::error($message, __CLASS__); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
$this->_opened = true; |
|
|
|
$this->updateFlashCounters(); |
|
|
|
$this->updateFlashCounters(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Ends the current session and store session data. |
|
|
|
* Ends the current session and store session data. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function close() |
|
|
|
public function close() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$this->_opened = false; |
|
|
|
if (session_id() !== '') { |
|
|
|
if (session_id() !== '') { |
|
|
|
@session_write_close(); |
|
|
|
@session_write_close(); |
|
|
|
} |
|
|
|
} |
|
|
@ -149,7 +157,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co |
|
|
|
return session_status() == PHP_SESSION_ACTIVE; |
|
|
|
return session_status() == PHP_SESSION_ACTIVE; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// this is not very reliable |
|
|
|
// this is not very reliable |
|
|
|
return session_id() !== ''; |
|
|
|
return $this->_opened && session_id() !== ''; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|