세션 처리

This commit is contained in:
2026-03-25 13:14:42 +09:00
parent 129e2b4e69
commit 7139e0c095

View File

@@ -58,9 +58,37 @@ class Session extends BaseConfig
* Please read up the manual for the format with other session drivers. * Please read up the manual for the format with other session drivers.
* *
* IMPORTANT: You are REQUIRED to set a valid save path! * 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 = 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';
}
}
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------