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'; + } + } /** * --------------------------------------------------------------------------