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. 微信公众平台开发—利用OAuth2.0获取微信用户基本信息

    在借鉴前两篇获取微信用户基本信息的基础下,本人也总结整理了一些个人笔记:如何通过OAuth2.0获取微信用户信息 1.首先在某微信平台下配置OAuth2.0授权回调页面: 2.通过appid构造url ...

  2. [转] Envelop

    xiaohaidepoli原文Envelop Envelope也称包络线,是一个矩形区域,是每个几何形体的最小外接矩形.每个Geometry都拥有一个Envelope,包括Envelope自身. 它定 ...

  3. Dos操作

    \tree/f >c.txt \dir/s/b >c.txt

  4. memcache redundancy机制分析及思考

    设计和开发可以掌控客户端的分布式服务端程序是件幸事,可以把很多事情交给客户端来做,而且可以做的很优雅.角色决定命运,在互联网架构中,web server必须冲锋在前,注定要在多浏览器版本以及协议兼容性 ...

  5. SqlServer中截取字符串

    SQL Server 中截取字符串常用的函数: .LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要截 ...

  6. js基础第八天

    返回前面起第一个字符位置 indexOf("sdfsdf");它是从左边索引为0开始数,而且只找第一个,然后返回该字符的位置.返回是个数值.如果找不到该字符,那么就会返回-1. 返 ...

  7. TCP 滑动窗口的简介

    TCP 滑动窗口的简介 POSTED BY ADMIN ON AUG 1, 2012 IN FLOWS34ARTICLES | 0 COMMENTS TCP的滑动窗口主要有两个作用,一是提供TCP的可 ...

  8. Java List 用法代码分析 非常详细

    Java中可变数组的原理就是不断的创建新的数组,将原数组加到新的数组中,下文对Java List用法做了详解. List:元素是有序的(怎么存的就怎么取出来,顺序不会乱),元素可以重复(角标1上有个3 ...

  9. 高级C++开发工程师综合测试题(风林火山)

    题目要求:代码要求能够直接编译运行 1.       请实现一个函数:凑14:输入很多个整数(1<=数值<=13),任意两个数相加等于14就可以从数组中删除这两个数,求剩余数(按由小到大排 ...

  10. 追MM与Java的23种设计模式

    1.Factory:追MM少不了请吃饭了,麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西,虽然口味有所不同,但不管你带MM去麦当劳或肯德基,只管向服务员说“来四个鸡翅”就行了.麦当劳和肯德基就是生产鸡翅 ...