zoukankan      html  css  js  c++  java
  • 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.
  • 相关阅读:
    springboot注解@NotNull,@NotBlank,@Valid自动判定空值
    idea打包java可执行jar包
    Spring Boot 默认支持的并发量
    SpringBoot+MyBatis+MySQL读写分离
    Spring+MyBatis实现数据库读写分离方案
    分布式数据库中间件、产品——sharding-jdbc、mycat、drds
    数据库分库分表、读写分离的原理实现,使用场景
    Mono 3.2.3 Socket功能迎来一稳定的版本
    .NET代码树执行时间计时器
    .net好好地利用Conditional属性
  • 原文地址:https://www.cnblogs.com/chunguang/p/5643024.html
Copyright © 2011-2022 走看看