Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ############# |
| 2 | Cookie Helper |
| 3 | ############# |
| 4 | |
| 5 | The Cookie Helper file contains functions that assist in working with |
| 6 | cookies. |
| 7 | |
| 8 | .. contents:: Page Contents |
| 9 | |
| 10 | Loading this Helper |
| 11 | =================== |
| 12 | |
| 13 | This helper is loaded using the following code |
| 14 | |
| 15 | :: |
| 16 | |
| 17 | $this->load->helper('cookie'); |
| 18 | |
| 19 | The following functions are available: |
| 20 | |
| 21 | set_cookie() |
| 22 | ============ |
| 23 | |
| 24 | This helper function gives you view file friendly syntax to set browser |
| 25 | cookies. Refer to the :doc:`Input class <../libraries/input>` for a |
| 26 | description of use, as this function is an alias to |
| 27 | `$this->input->set_cookie()`. |
| 28 | |
| 29 | .. php:method:: set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) |
| 30 | |
| 31 | :param string $name: the name of the cookie |
| 32 | :param string $value: the value of the cookie |
| 33 | :param string $expire: the number of seconds until expiration |
| 34 | :param string $domain: the cookie domain. Usually: .yourdomain.com |
| 35 | :param string $path: the cookie path |
| 36 | :param string $prefix: the cookie prefix |
| 37 | :param boolean $secure: secure cookie or not. |
| 38 | :returns: void |
| 39 | |
| 40 | get_cookie() |
| 41 | ============ |
| 42 | |
| 43 | This helper function gives you view file friendly syntax to get browser |
| 44 | cookies. Refer to the :doc:`Input class <../libraries/input>` for a |
| 45 | description of use, as this function is an alias to `$this->input->cookie()`. |
| 46 | |
| 47 | .. php:method:: get_cookie($index = '', $xss_clean = FALSE) |
| 48 | |
| 49 | :param string $index: the name of the cookie |
| 50 | :param boolean $xss_clean: If the resulting value should be xss_cleaned or not |
| 51 | :returns: mixed |
| 52 | |
| 53 | delete_cookie() |
| 54 | =============== |
| 55 | |
| 56 | Lets you delete a cookie. Unless you've set a custom path or other |
| 57 | values, only the name of the cookie is needed |
| 58 | |
| 59 | .. php:method:: delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') |
| 60 | |
| 61 | :param string $name: the name of the cookie |
| 62 | :param string $domain: cookie domain (ususally .example.com) |
| 63 | :param string $path: cookie path |
| 64 | :param string $prefix: cookie prefix |
| 65 | :returns: void |
| 66 | |
| 67 | :: |
| 68 | |
| 69 | delete_cookie("name"); |
| 70 | |
| 71 | This function is otherwise identical to ``set_cookie()``, except that it |
| 72 | does not have the value and expiration parameters. You can submit an |
| 73 | array of values in the first parameter or you can set discrete |
| 74 | parameters. |
| 75 | |
| 76 | :: |
| 77 | |
| 78 | delete_cookie($name, $domain, $path, $prefix) |