blob: e70893f2f18b34117ed312c6176b04b21e573cca [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
Derek Jonesb55d9812013-07-20 08:49:25 -07008.. contents::
9 :local:
10
11.. raw:: html
12
13 <div class="custom-index container"></div>
Derek Jones8ede1a22011-10-05 13:34:52 -050014
15Loading this Helper
16===================
17
Andrey Andreev48a86752012-11-08 15:16:34 +020018This helper is loaded using the following code::
Derek Jones8ede1a22011-10-05 13:34:52 -050019
20 $this->load->helper('cookie');
21
Derek Jonesb55d9812013-07-20 08:49:25 -070022Available Functions
23===================
24
Derek Jones8ede1a22011-10-05 13:34:52 -050025The following functions are available:
26
Derek Jones8ede1a22011-10-05 13:34:52 -050027
Derek Jones26f7a9f2013-07-20 09:00:02 -070028.. function:: set_cookie([$name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]]])
Andrey Andreev48a86752012-11-08 15:16:34 +020029
Derek Jonesb55d9812013-07-20 08:49:25 -070030 :param mixed $name: Cookie name *or* associative array of all of
31 the parameters available to this function
Andrey Andreev48a86752012-11-08 15:16:34 +020032 :param string $value: Cookie value
33 :param int $expire: Number of seconds until expiration
34 :param string $domain: Cookie domain (usually: .yourdomain.com)
35 :param string $path: Cookie path
36 :param string $prefix: Cookie name prefix
37 :param bool $secure: Whether to only send the cookie through HTTPS
38 :param bool $httponly: Whether to hide the cookie from JavaScript
39 :returns: void
40
Derek Jonesb55d9812013-07-20 08:49:25 -070041 This helper function gives you view file friendly syntax to set browser
42 cookies. Refer to the :doc:`Input Library <../libraries/input>` for a
43 description of its use, as this function is an alias for
44 ``CI_Input::set_cookie()``.
Derek Jones8ede1a22011-10-05 13:34:52 -050045
Derek Jones8ede1a22011-10-05 13:34:52 -050046
Derek Jones26f7a9f2013-07-20 09:00:02 -070047.. function:: get_cookie([$index = ''[, $xss_clean = FALSE]])
Andrey Andreev48a86752012-11-08 15:16:34 +020048
49 :param string $index: Cookie name
50 :param bool $xss_clean: Whether to apply XSS filtering to the returned value
51 :returns: mixed
52
Derek Jonesb55d9812013-07-20 08:49:25 -070053 This helper function gives you view file friendly syntax to get browser
54 cookies. Refer to the :doc:`Input Library <../libraries/input>` for a
55 description of its use, as this function is an alias for ``CI_Input::cookie()``.
Derek Jones8ede1a22011-10-05 13:34:52 -050056
Derek Jones8ede1a22011-10-05 13:34:52 -050057
Derek Jones26f7a9f2013-07-20 09:00:02 -070058.. function:: delete_cookie([$name = ''[, $domain = ''[, $path = '/'[, $prefix = '']]]])
Derek Jones8ede1a22011-10-05 13:34:52 -050059
Andrey Andreev48a86752012-11-08 15:16:34 +020060 :param string $name: Cookie name
61 :param string $domain: Cookie domain (usually: .yourdomain.com)
62 :param string $path: Cookie path
63 :param string $prefix: Cookie name prefix
Derek Jones8ede1a22011-10-05 13:34:52 -050064 :returns: void
65
Derek Jonesb55d9812013-07-20 08:49:25 -070066 Lets you delete a cookie. Unless you've set a custom path or other
67 values, only the name of the cookie is needed.
Andrey Andreev48a86752012-11-08 15:16:34 +020068
Derek Jonesb55d9812013-07-20 08:49:25 -070069 ::
Derek Jones8ede1a22011-10-05 13:34:52 -050070
Derek Jonesb55d9812013-07-20 08:49:25 -070071 delete_cookie('name');
Derek Jones8ede1a22011-10-05 13:34:52 -050072
Derek Jonesb55d9812013-07-20 08:49:25 -070073 This function is otherwise identical to ``set_cookie()``, except that it
74 does not have the value and expiration parameters. You can submit an
75 array of values in the first parameter or you can set discrete
76 parameters.
Derek Jones8ede1a22011-10-05 13:34:52 -050077
Derek Jonesb55d9812013-07-20 08:49:25 -070078 ::
Derek Jones8ede1a22011-10-05 13:34:52 -050079
Derek Jonesb55d9812013-07-20 08:49:25 -070080 delete_cookie($name, $domain, $path, $prefix)