Session 1.0.0
             2020-12-26
             885次浏览
        
        Session package implements a session service, PSR-15 session middleware, and a flash message service which helps use one-time messages.
You can access session data through SessionInterface.
/** @var \Yiisoft\Session\SessionInterface $session */
$myId = $session->get('my_id');
if ($myId === null) {
    $session->set('my_id', 42);
}
In case you need some data to remain in session until read, such as in case with displaying a message on the next page, FlashInteface is your friend:
/** @var Yiisoft\Session\Flash\FlashInterface $flash */
// request 1
$flash->set('warning', 'Oh no, not again.');
// request 2
$warning = $flash->get('warning');
if ($warning !== null) {
    // do something with it
}
新闻归档
热门标签
- yii3
 - 扩展
 - 发布
 - yii2
 - debug
 - view
 - auth client
 - html
 - bootstrap
 - release
 - mongodb
 - redis
 - apidoc
 - Yii 1.1
 - validation
 - Yii 2.0
 - http
 - runner
 - extensions
 - console
 - error handler
 - gii
 - mailer
 - cache
 - http 客户端
 - queue
 - twig
 - hydrator
 - translator
 - widget
 - sphinx
 - router
 - log
 - symfonymailer
 - assets
 - config
 - db
 - swagger
 - middleware
 - imagine
 - elasticsearch
 - 图书
 - swiftmailer
 - widgets
 - definitions
 - i18n
 - IDE
 - fastroute
 - csrf
 - user