본문 바로가기

728x90
반응형

코드이그나이터

(5)
같은 서비스에 서브 도메인의 세션을 공유하기 CodeIgniter 4 (CI4)에서 서브 도메인 간 세션 공유는 기본적으로 쿠키를 통해 처리됩니다. 세션 데이터를 서브 도메인 간에 공유하려면 몇 가지 설정이 필요합니다. 환경 설정 파일 설정 (app/Config/App.php): 다음 설정을 확인하고 수정합니다. public $baseURL = 'http://yourdomain.com'; public $cookieDomain = '.yourdomain.com'; public $cookiePath = '/'; public $cookiePrefix = 'yourprefix_'; public $cookieSecure = false; // HTTPS를 사용하는 경우 true로 변경 public $cookieSameSite = 'Lax'; // 필요에 따라..
cookie 쿠키 사용 helper('cookie'); $cookie = array( 'name' => 'The Cookie Name', 'value' => 'The Value', 'expire' => '86500', 'domain' => '.some-domain.com', 'path' => '/', 'prefix' => 'myprefix_', ); set_cookie($cookie); 쿠키 불러오기 get_cookie('The Cookie Name')
폼검증 $rules['email'] = 'required|min_length[6]|max_length[50]|valid_email|is_unique[user.email]'; if($this->validate($rules)){ echo "true"; }else{ echo "false"; }
debugger 없애기 /* |-------------------------------------------------------------------------- | ERROR DISPLAY |-------------------------------------------------------------------------- | In development, we want to show as many errors as possible to help | make sure they don't make it to production. And save us hours of | painful debugging. */ error_reporting(-1); ini_set('display_errors', '1'); /* |----------..
[CI4] Codeigniter alert helper 만들기 헬퍼(helper) 헬퍼는 코드이그나이터에서 객체 지향(OOP) 형식으로 작성되지 않고 자유롭게 함수를 만들고 사용할 수 있다. 예를 들어 스크립트를 view에서 처리를 할때 컨트롤 단에서 매번 echo ""; } // alert 띄우고 뒤로 이동 function alert_back($text) { echo ""; } // alert 띄우고 창닫기 function alert_close($text) { echo ""; } // alert 띄우고 이동 function alert_move($text, $geturl) { echo ""; } 이렇게 만들어 놓고 쓰면 편하다. 컨트롤러 사용 예시 public function __construct() { /* * * 헬퍼 로드시 파일명이 script_helper.p..

728x90
반응형