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

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

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

問題描述

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

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);

默認值如下:

'lifetime' => 15,

我正在開發的網站對大多數用戶的會話生命周期非常短,但對于選定的用戶,我想提供更長的會話生命周期.

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.

推薦答案

似乎實現動態 lifetime 值的唯一方法是在會話啟動之前在中間件中設置該值.否則為時已??晚,因為應用程序 SessionHandler 已經使用默認配置值進行了實例化.

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,

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

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

相關文檔推薦

add new element in laravel collection object(在 Laravel 集合對象中添加新元素)
Creating an edit modal in Laravel 5(在 Laravel 5 中創建編輯模式)
Laravel 5.5 API resources for collections (standalone data)(用于集合的 Laravel 5.5 API 資源(獨立數據))
What is the best practice to create a custom helper function in php Laravel 5?(在 php Laravel 5 中創建自定義輔助函數的最佳實踐是什么?)
No #39;Access-Control-Allow-Origin#39; header - Laravel(沒有“Access-Control-Allow-Origin標頭 - Laravel)
Laravel Passport Route redirects to login page(Laravel Passport Route 重定向到登錄頁面)
主站蜘蛛池模板: 天天射天天干 | 天堂亚洲 | 91精品国产高清一区二区三区 | 99久久精品免费看国产四区 | 精品网站999www | 午夜影院在线观看 | 不卡视频一区二区三区 | 国产精品69毛片高清亚洲 | 亚洲自拍偷拍免费视频 | 自拍偷拍亚洲视频 | 男女那个视频 | 人人操日日干 | 国产精品日韩欧美一区二区三区 | 国产精品久久久99 | 色婷婷av久久久久久久 | 亚洲精品久久久一区二区三区 | 日本成人中文字幕在线观看 | 日韩中文字幕在线不卡 | 91久久精品国产 | 欧美成人久久 | 懂色tv | 欧美成年人视频在线观看 | 欧美性受xxx| 国产精品成人一区二区三区 | 日韩精品一区二区三区中文字幕 | 玖玖久久 | 国产伦精品一区二区三区四区视频 | 97超碰成人 | 日韩欧美国产一区二区 | 亚洲综合色视频在线观看 | 亚洲精品乱码久久久久v最新版 | 亚洲精品99 | 国产精品国产a级 | 国产精品久久久久久久久久久久久 | 黄色大片毛片 | 精品视频一区二区 | 国产日韩精品一区 | 国产免费视频 | 国产电影一区二区 | 国产高清一区二区 | 狠狠干av |