Commit c56647ff by Qiang Xue

Merge pull request #1757 from nineinchnick/1476_session_handler

Add handler property to yii\web\Session
parents f2fb7de5 7e1e6224
......@@ -36,6 +36,7 @@ Yii Framework 2 Change Log
- Enh #1406: DB Schema support for Oracle Database (p0larbeer, qiangxue)
- Enh #1437: Added ListView::viewParams (qiangxue)
- Enh #1469: ActiveRecord::find() now works with default conditions (default scope) applied by createQuery (cebe)
- Enh #1476: Add yii\web\Session::handler property (nineinchnick)
- Enh #1499: Added `ActionColumn::controller` property to support customizing the controller for handling GridView actions (qiangxue)
- Enh #1523: Query conditions now allow to use the NOT operator (cebe)
- Enh #1552: It is now possible to use multiple bootstrap NavBar in a single page (Alex-Code)
......
......@@ -81,6 +81,10 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
*/
public $flashVar = '__flash';
/**
* @var \SessionHandlerInterface|array an object implementing the SessionHandlerInterface or a configuration array. If set, will be used to provide persistency instead of build-in methods.
*/
public $handler;
/**
* @var array parameter-value pairs to override default session cookie parameters that are used for session_set_cookie_params() function
* Array may have the following possible keys: 'lifetime', 'path', 'domain', 'secure', 'httpOnly'
* @see http://www.php.net/manual/en/function.session-set-cookie-params.php
......@@ -121,7 +125,15 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
return;
}
if ($this->getUseCustomStorage()) {
if ($this->handler !== null) {
if (!is_object($this->handler)) {
$this->handler = Yii::createObject($this->handler);
}
if (!$this->handler instanceof \SessionHandlerInterface) {
throw new InvalidConfigException('"' . get_class($this) . '::handler" must implement the SessionHandlerInterface.');
}
@session_set_save_handler($this->handler, false);
} elseif ($this->getUseCustomStorage()) {
@session_set_save_handler(
[$this, 'openSession'],
[$this, 'closeSession'],
......
Markdown is supported
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