blob: 30e601c3274bf6436d4bc3b0efa57ebb0782f489 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001#############
2Cookie Helper
3#############
4
5The Cookie Helper file contains functions that assist in working with
6cookies.
7
8.. contents:: Page Contents
9
10Loading this Helper
11===================
12
13This helper is loaded using the following code
14
15::
16
17 $this->load->helper('cookie');
18
19The following functions are available:
20
21set_cookie()
22============
23
24This helper function gives you view file friendly syntax to set browser
25cookies. Refer to the :doc:`Input class <../libraries/input>` for a
26description 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
40get_cookie()
41============
42
43This helper function gives you view file friendly syntax to get browser
44cookies. Refer to the :doc:`Input class <../libraries/input>` for a
45description 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
53delete_cookie()
54===============
55
56Lets you delete a cookie. Unless you've set a custom path or other
57values, 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
71This function is otherwise identical to ``set_cookie()``, except that it
72does not have the value and expiration parameters. You can submit an
73array of values in the first parameter or you can set discrete
74parameters.
75
76::
77
78 delete_cookie($name, $domain, $path, $prefix)