Session Store

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.

Session Store的更多相关文章

  1. 在Apache Tomcat 7设置redis作为session store

    在Apache Tomcat 7设置redis作为session store  //输出tomcat控制台日志 root@ubuntu:~# cd /usr/tomcat/apache-tomcat- ...

  2. MongoDB实践-自定义ASP.NET Session Store

    Session由来 由于HTTP协议是无状态的,客户端与服务器端进行“请求-响应”操作后,建立的连接就释放了,服务器端根本不知道刚才是哪个客户端访问的.但是有些场景是需要知道客户端的状态的,最典型的就 ...

  3. No Spring Session store is configured: set the 'spring.session.store-type'

    发现session store type使用来存放session的存储方式,目前Spring boot中只支持Redis方式. 由于本应用暂无需将session放入redis的需求,故这里就可以将se ...

  4. Spring.之.报错:Caused by: java.lang.IllegalArgumentException: No Spring Session store is configured: set the 'spring.session.store-type' property

    Spring.之.报错 No Spring Session store is configured springboot在启动的时候报如下错误: Error starting ApplicationC ...

  5. laravel5.6中Session store not set on request问题如何解决

    先找到文件app下的Kernel.php文件,在文件中加入下列代码 protected $middleware = [ \Illuminate\Foundation\Http\Middleware\C ...

  6. session一直报错Session store not set on request

    Route::group(['middleware' => ['web']], function () { //});仍然报错,看了 session是使用默认file,没问题:app/stora ...

  7. php about session store db or cache

    PHP关于Session的配置: 在php.ini中配置为:session.name = PHPSESSID 在请求开始的时候,会话名称会被重置并存储到session.name配置项. 所以要想在不改 ...

  8. spring boot项目启动报(No session repository could be auto-configured, check your configuration (session store type is 'null'))

    找到项目的application配置文件,增加 spring.session.store-type=none,重新启动问题解决 注:因为项目未使用redis管理session,可以如上设置,如果想使用 ...

  9. Using Redis as Django's session store and cache backend

    http://michal.karzynski.pl/blog/2013/07/14/using-redis-as-django-session-store-and-cache-backend/

随机推荐

  1. shell脚本编写笔记

    包含转载内容,转载自http://wenku.baidu.com/link?url=jtCHxEYzgGve6P64U3JRQRgU6nhpGvqFLLpWu9I2Htq6hi9TGLudRFkk7r ...

  2. ArcGIS for Android示例解析之离线地图-----LocalTiledLayer

    转自:http://blog.csdn.net/wozaifeiyang0/article/details/7327423 LocalTiledLayer 看到这个标题是否是很激动,如题,该示例就是添 ...

  3. 用JDBC访问ORACLE数据库 关于commit 增快效率 大数据 等的整理

    1.问:用JDBC访问ORACLE数据库,做DELETE操作,能用JAVA多线程实现吗? ORACLE服务器要怎么配?(以下答案来自网络,仅供参考) 答: Oracle有自己的锁机制.就算你开100条 ...

  4. delphi通过OLE对word进行单元格合并操作

    uses comobj, word2000procedure TForm1.Button2Click(Sender: TObject);var WordApp, WordDoc,table: OleV ...

  5. Java Web程序工作原理

    Web开发的最重要的基本功能是HTTP:Java Web开发的最重要的基本功是Servlet Specification.HTTP和Servlet Specitication对于Web Server和 ...

  6. 单元测试工具之Xunit

    在.NET开发中的单元测试工具之——xUnit.Net  原始出处 http://zhoufoxcn.blog.51cto.com/792419/1172320 在上一篇<在.NET开发中的单元 ...

  7. 【暑假】[深入动态规划]UVa 1380 A Scheduling Problem

     UVa 1380 A Scheduling Problem 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=41557 ...

  8. POJ 2955 Brackets 区间合并

    输出一个串里面能匹配的括号数 状态转移方程: if(s[i]=='('&&s[j]==')'||s[i]=='['&&s[j]==']')             dp ...

  9. 题目1043:Day of Week(输入日期与当前日起天数差%7,在做相关星期调整)

    题目描述: We now use the Gregorian style of dating in Russia. The leap years are years with number divis ...

  10. openstack fe