728x90
ci4 cookie 쿠키
1번 방법
$this->response->setCookie(
'cookie_name' //쿠키명
, $value // 값
, 3600 // 시간
)
;
return; // <<<< 중요하다
2번방법
$this->response->setCookie(
'cookie_name' //쿠키명
, $value // 값
, 3600 // 시간
)
;
$this->response->send(); // <<<< 중요하다.
exit;
헬퍼 사용추가
1 . 여전히 return 필요
helper('cookie');
// 쿠키 설정
set_cookie('user_id', '12345', 3600);
// 응답 반환
return '쿠키가 설정되었습니다.';
2. $this->response->send(); 반드시 필요.
helper('cookie');
// 쿠키 설정
set_cookie('user_id', '12345', 3600);
// 강제로 응답 전송
$this->response->send(); // 헬퍼써도 이건똑같네
728x90
'php 헛다리 > CI4 헛다리' 카테고리의 다른 글
ci4 - aws redis ( Valkey ) 설정 (0) | 2025.02.06 |
---|---|
ci4 - aws s3 파일업로드 (0) | 2025.02.04 |
ci4 파서사용시 자바스크립트 알수없는 Syntax 에러 (0) | 2024.11.11 |
CI4 컨트롤러에서 모델 호출하는 방법 (0) | 2024.11.10 |
ci4 parser 파서 (0) | 2024.10.10 |