Browse Source

Merge pull request #1757 from nineinchnick/1476_session_handler

Add handler property to yii\web\Session
tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
c56647ff4c
  1. 1
      framework/CHANGELOG.md
  2. 14
      framework/yii/web/Session.php

1
framework/CHANGELOG.md

@ -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)

14
framework/yii/web/Session.php

@ -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'],

Loading…
Cancel
Save