Session Store
2016-07-05 11:30
393 查看
Session Store
ConfigurationSession Usage
Flash Data
Session Drivers
Configuration
Since HTTP driven applications are stateless, sessions provide a way to store information about the user across requests. Nova ships with a variety of session back-ends available for use through a clean, unified API.The session configuration is stored in app/Config/Session.php. Be sure to review the well documented options available to you in this file. By default, Nova is configured to use the file session driver, which will work well for the majority of applications.
Reserved Keys
The Nova framework uses the flash session key internally, so you should not add an item to the session by that name.Session Usage
Storing An Item In The Session
Session::put('key', 'value');
Push A Value Onto An Array Session Value
Session::push('user.teams', 'developers');
Retrieving An Item From The Session
$value = Session::get('key');
Retrieving An Item Or Returning A Default Value
$value = Session::get('key', 'default'); $value = Session::get('key', function() { return 'default'; });
Retrieving An Item And Forgetting It
$value = Session::remove('key', 'default');
Retrieving All Data From The Session
$data = Session::all();
Determining If An Item Exists In The Session
if (Session::has('users')) { // }
Removing An Item From The Session
Session::forget('key');
Removing All Items From The Session
Session::flush();
Regenerating The Session ID
Session::regenerate();
Flash Data
Sometimes you may wish to store items in the session only for the next request. You may do so using the Session::flash method:Session::flash('key', 'value');
Reflashing The Current Flash Data For Another Request
Session::reflash();
Reflashing Only A Subset Of Flash Data
Session::keep(array('username', 'email'));
Session Drivers
The session "driver" defines where session data will be stored for each request. Nova ships with several great drivers out of the box:file - sessions will be stored in app/Storage/Sessions.
database - sessions will be stored in a database used by your application.
相关文章推荐
- Response
- java class reload 动态加载
- CentOS7配置samba4.2到Win8
- lucene 存储,访问小技巧
- RecyclerView实现填加头部
- lucene 4.6 之indexing 之 IndexWriter, DocumentWriter
- TYVJ1403(NOIP2010提高组T3)关押罪犯
- ionic 实现拨打电话、发短信、发邮件功能
- 实用sql语句
- centos 搭建 httpd 服务器 以及配置多域名 反向代理
- lucene 4.6 之索引文件格式
- 论代码稳定
- 工作框架各种使用整理---自己处理分页
- GetProcAddress 使用注意事项
- Redirect
- Jsoup的简单使用
- OpenJudge百炼 1321 棋盘问题
- lucene 之 全文检索概述
- #if 与#endif
- C#学习篇(三)C#关键字this和base