From 7139e0c095142601d9f5212c938a92167d8521c1 Mon Sep 17 00:00:00 2001 From: jjstyle Date: Wed, 25 Mar 2026 13:14:42 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=B8=EC=85=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Config/Session.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/Config/Session.php b/app/Config/Session.php index b60b6ed..1243f93 100644 --- a/app/Config/Session.php +++ b/app/Config/Session.php @@ -58,9 +58,37 @@ class Session extends BaseConfig * Please read up the manual for the format with other session drivers. * * IMPORTANT: You are REQUIRED to set a valid save path! + * + * For Redis: tcp://host:port?database=n&password=xxx */ // public string $savePath = WRITEPATH . 'session'; - public string $savePath = ''; + public string $savePath; + + public function __construct() + { + parent::__construct(); + + // Redis 설정을 환경변수에서 불러오기 + if ($this->driver === RedisHandler::class) { + $redisHost = env('REDIS_HOST', '127.0.0.1'); + $redisPort = env('REDIS_PORT', '6379'); + $redisDatabase = env('REDIS_DATABASE', '0'); + $redisPassword = env('REDIS_PASSWORD', ''); + + $this->savePath = sprintf( + 'tcp://%s:%s?database=%s', + $redisHost, + $redisPort, + $redisDatabase + ); + + if (!empty($redisPassword)) { + $this->savePath .= '&password=' . $redisPassword; + } + } else { + $this->savePath = WRITEPATH . 'session'; + } + } /** * --------------------------------------------------------------------------