php 헛다리/CI4 헛다리
ci4 cookie 쿠키
후닝요
2024. 12. 26. 18:43
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