久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Laravel 在用戶級別自定義 session.lifetime

Laravel customized session.lifetime at user level(Laravel 在用戶級別自定義 session.lifetime)
本文介紹了Laravel 在用戶級別自定義 session.lifetime的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在其中一個中間件(用于 Laravel Web 應(yīng)用程序)中覆蓋 session.timeout 值,但它似乎不會影響會話超時.雖然如果我調(diào)試它會顯示我已經(jīng)覆蓋的值.

I am overwriting session.timeout value in one of the middleware (for Laravel web app) but it doesn't seem to be affecting in terms of timing out a session. Though if I debug it shows value I have overwritten.

Config::set('session.lifetime', 1440);

默認(rèn)值如下:

'lifetime' => 15,

我正在開發(fā)的網(wǎng)站對大多數(shù)用戶的會話生命周期非常短,但對于選定的用戶,我想提供更長的會話生命周期.

Website that I am working on has very short session lifetime for most of the users but for selected users I want to provide extended session lifetime.

推薦答案

似乎實現(xiàn)動態(tài) lifetime 值的唯一方法是在會話啟動之前在中間件中設(shè)置該值.否則為時已??晚,因為應(yīng)用程序 SessionHandler 已經(jīng)使用默認(rèn)配置值進(jìn)行了實例化.

It seems the only way to accomplish a dynamic lifetime value, is by setting the value in middleware, before the session gets initiated. Otherwise its too late, as the application SessionHandler will have already been instantiated using the default config value.

namespace AppHttpMiddleware;

class ExtendSession
{
    /**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     */
    public function handle($request, $next)
    {
        $lifetime = 2;
        config(['session.lifetime' => $lifetime]);
        return $next($request);
    }
}

然后在kernel.php文件中,在StartSession之前添加這個類.

Then in the kernel.php file, add this class prior to StartSession.

AppHttpMiddlewareExtendSession::class,
IlluminateSessionMiddlewareStartSession::class,

這篇關(guān)于Laravel 在用戶級別自定義 session.lifetime的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

add new element in laravel collection object(在 Laravel 集合對象中添加新元素)
Creating an edit modal in Laravel 5(在 Laravel 5 中創(chuàng)建編輯模式)
Laravel 5.5 API resources for collections (standalone data)(用于集合的 Laravel 5.5 API 資源(獨立數(shù)據(jù)))
What is the best practice to create a custom helper function in php Laravel 5?(在 php Laravel 5 中創(chuàng)建自定義輔助函數(shù)的最佳實踐是什么?)
No #39;Access-Control-Allow-Origin#39; header - Laravel(沒有“Access-Control-Allow-Origin標(biāo)頭 - Laravel)
Laravel Passport Route redirects to login page(Laravel Passport Route 重定向到登錄頁面)
主站蜘蛛池模板: av影片在线| 一区二区在线免费观看 | 免费成人毛片 | 精品国产黄a∨片高清在线 成人区精品一区二区婷婷 日本一区二区视频 | 羞羞色在线观看 | 成人a免费 | 91久久综合 | 亚洲精品一区在线观看 | 在线视频亚洲 | 亚洲毛片一区二区 | 亚洲一区二区三区在线 | 成人h视频在线观看 | 欧美国产日韩一区二区三区 | 国产免费一区二区 | 国产一在线观看 | 99re热精品视频 | 久久久福利 | 欧美不卡一区 | 国产在线视频一区二区董小宛性色 | 欧美综合久久 | 99久久久久 | 亚洲国产区 | 激情国产 | 成人不卡视频 | 日本a∨精品中文字幕在线 亚洲91视频 | 亚洲精品久久久一区二区三区 | 白浆在线 | 久久一日本道色综合久久 | 久久久久亚洲国产| 亚洲一区二区三区四区五区中文 | 在线视频一区二区三区 | 国产精品久久久久久一区二区三区 | 久久人人网 | 国产清纯白嫩初高生视频在线观看 | 特级a欧美做爰片毛片 | 欧美激情欧美激情在线五月 | www.99热这里只有精品 | 午夜视频一区二区三区 | 久久精品久久综合 | 精品国产一区二区 | 福利视频一区二区 |