Session Store

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.
时间: 2024-10-05 09:34:41

Session Store的相关文章

在Apache Tomcat 7设置redis作为session store

在Apache Tomcat 7设置redis作为session store redis已经有组件支持直接在tomcat7中设置下将redis作为tomcat默认的session存储器,下面介绍下配置过程 1.从http://redis.io/下载redis,按照redis服务端 wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable make 2.启动redis

spring boot之session store type is 'null'

在网上搜索之后,发现session store type使用来存放session的存储方式,目前Spring boot中只支持Redis方式. 由于本应用暂无需将session放入redis的需求,故这里就可以将session store type设置为none. 这里我们将此配置信息放入application.properites之中: # default-store in spring session. it will be set in redis only outside. spring

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

发现session store type使用来存放session的存储方式,目前Spring boot中只支持Redis方式. 由于本应用暂无需将session放入redis的需求,故这里就可以将session store type设置为none. 这里我们将此配置信息放入application.properites之中: # default-store in spring session. it will be set in redis only outside. spring.session

express session store

express-session http://www.expressjs.com.cn/en/resources/middleware/session.html var session = require('express-session') store The session store instance, defaults to a new MemoryStore instance. express-session提供了基本的会话功能, 让服务器端具有存储用户访问状态的能力, 例如登录过了,

Ubuntu上使用Redis数据库存储SessionID并实现Session共享

p { margin-bottom: 0.1in; direction: ltr; color: #00000a; line-height: 120%; text-align: left; orphans: 2; widows: 2 } p.western { font-family: "Liberation Serif", serif; font-size: 12pt } p.cjk { font-family: "Noto Sans CJK SC Regular"

express配置session的几种场景

多个node实例同时运行的情况下,session的处理比单实例的场景更复杂,以2个node节点为例 单一域名的场景 只有一个域名的场景比较简单,只要把session的store和secret配置成一样,就可以实现session共享 .use("/svc", express.session({ store: new MongoStore({ url: 'mongodb://127.0.0.1:2222/my_session' }), cookie: { maxAge: 60 * 60 *

express 4 使用session和cookies

https://my.oschina.net/u/1466553/blog/294336 http://blog.csdn.net/liyi109030/article/details/35271389 express是基于node.js的一个web框架,但是到了4.xx版本之后,session管理和cookies等许多模块都不再直接包含在express中,而是需要单独下载添加. var express = require('express'); var session = require('e

Webx学习笔记(八)Request Context之Session

1 Session概述 HTTP协议是无状态的,但通过session机制,就能把无状态的变成有状态的.Session的功能就是保存HTTP请求之间的状态数据.有了session的支持,就很容易实现诸如用户登录.购物车等网站功能.在Servlet API中,有一个HttpSession的接口. 在Java代码中访问session //在一个请求中,保存session的状态 // 取得session对象 HttpSession session = request.getSession(); // 在

asp.net mvc Session RedisSessionStateProvider锁的实现

最近项目用到了RedisSessionStateProvider来保存session,发现比内存session慢,后来慢慢了解,发现asp.net session是有锁的.我在文章 你的项目真的需要Session吗? redis保存session性能怎么样?也提到一些观点,本来打算在那篇文章补充一些类容,后来想了一下,还是重写一个短文吧.有关session 管道流程大家 可以参考 Asp.net Session认识加强-Session究竟是如何存储你知道吗? 我们的mvc程序都是有路由信息,那么