CodeIgniter4
  • CodeIgniter4에 어서 오세요.
  • 설치하기
  • Tutorial
  • CodeIgniter4 개요
  • 일반적인 주제
  • 컨트롤러 및 라우팅
  • 요청 처리
  • 데이터베이스 작업
  • 데이타 모델링
  • 데이터베이스 관리
  • 라이브러리
  • Helpers
    • Array Helper
    • Cookie Helper
    • Date Helper
    • Filesystem Helper
    • Form Helper
    • HTML Helper
    • Inflector Helper
    • Number Helper
    • Security Helper
    • Text Helper
    • URL Helper
    • XML Helper
  • 테스트
  • 컨맨드 라인 사용
  • CodeIgniter 확장
  • The MIT License (MIT)
  • Change Logs
CodeIgniter4
  • Docs »
  • Helpers »
  • Cookie Helper

Cookie Helper¶

The Cookie Helper file contains functions that assist in working with cookies.

  • Loading this Helper
  • Available Functions

Loading this Helper¶

This helper is loaded using the following code:

helper('cookie');

Available Functions¶

The following functions are available:

set_cookie($name[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = false[, $httpOnly = false]]]]]]])¶
Parameters:
  • $name (mixed) – Cookie name or associative array of all of the parameters available to this function
  • $value (string) – Cookie value
  • $expire (int) – Number of seconds until expiration
  • $domain (string) – Cookie domain (usually: .yourdomain.com)
  • $path (string) – Cookie path
  • $prefix (string) – Cookie name prefix
  • $secure (bool) – Whether to only send the cookie through HTTPS
  • $httpOnly (bool) – Whether to hide the cookie from JavaScript
Return type:

void

This helper function gives you friendlier syntax to set browser cookies. Refer to the Response Library for a description of its use, as this function is an alias for Response::setCookie().

get_cookie($index[, $xssClean = false])¶
Parameters:
  • $index (string) – Cookie name
  • $xss_clean (bool) – Whether to apply XSS filtering to the returned value
Returns:

The cookie value or NULL if not found

Return type:

mixed

This helper function gives you friendlier syntax to get browser cookies. Refer to the IncomingRequest Library for detailed description of its use, as this function acts very similarly to IncomingRequest::getCookie(), except it will also prepend the $cookiePrefix that you might’ve set in your app/Config/App.php file.

delete_cookie($name[, $domain = ''[, $path = '/'[, $prefix = '']]])¶
Parameters:
  • $name (string) – Cookie name
  • $domain (string) – Cookie domain (usually: .yourdomain.com)
  • $path (string) – Cookie path
  • $prefix (string) – Cookie name prefix
Return type:

void

Lets you delete a cookie. Unless you’ve set a custom path or other values, only the name of the cookie is needed.

delete_cookie('name');

This function is otherwise identical to set_cookie(), except that it does not have the value and expiration parameters. You can submit an array of values in the first parameter or you can set discrete parameters.

delete_cookie($name, $domain, $path, $prefix);
Next Previous

© Copyright 2014-2019 British Columbia Institute of Technology. Last updated on Dec 12, 2019.

Built with Sphinx using a theme provided by Read the Docs.