blob: 2821fadb1a982351ad0d5a30814ea64b86838957 [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Derek Jones7f3719f2010-01-05 13:35:37 +00009 * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * CodeIgniter Cookie Helpers
20 *
21 * @package CodeIgniter
22 * @subpackage Helpers
23 * @category Helpers
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/helpers/cookie_helper.html
26 */
27
28// ------------------------------------------------------------------------
29
30/**
31 * Set cookie
32 *
33 * Accepts six parameter, or you can submit an associative
34 * array in the first parameter containing all the values.
35 *
36 * @access public
37 * @param mixed
38 * @param string the value of the cookie
39 * @param string the number of seconds until expiration
40 * @param string the cookie domain. Usually: .yourdomain.com
41 * @param string the cookie path
42 * @param string the cookie prefix
43 * @return void
44 */
45if ( ! function_exists('set_cookie'))
46{
47 function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
48 {
Derek Allard2067d1a2008-11-13 22:59:24 +000049 // Set the config file options
50 $CI =& get_instance();
Derek Jones22224b52010-03-02 23:06:53 -060051 $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix);
Derek Allard2067d1a2008-11-13 22:59:24 +000052 }
53}
Barry Mienydd671972010-10-04 16:33:58 +020054
Derek Allard2067d1a2008-11-13 22:59:24 +000055// --------------------------------------------------------------------
56
57/**
58 * Fetch an item from the COOKIE array
59 *
60 * @access public
61 * @param string
62 * @param bool
63 * @return mixed
64 */
65if ( ! function_exists('get_cookie'))
66{
67 function get_cookie($index = '', $xss_clean = FALSE)
68 {
Derek Jonesa04cfa72009-02-10 20:16:57 +000069 $CI =& get_instance();
Barry Mienydd671972010-10-04 16:33:58 +020070
Derek Jones2c8dc582009-02-10 20:15:49 +000071 $prefix = '';
Barry Mienydd671972010-10-04 16:33:58 +020072
Derek Jones2c8dc582009-02-10 20:15:49 +000073 if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
74 {
75 $prefix = config_item('cookie_prefix');
76 }
Barry Mienydd671972010-10-04 16:33:58 +020077
Derek Jones2c8dc582009-02-10 20:15:49 +000078 return $CI->input->cookie($prefix.$index, $xss_clean);
Derek Allard2067d1a2008-11-13 22:59:24 +000079 }
80}
81
82// --------------------------------------------------------------------
83
84/**
85 * Delete a COOKIE
86 *
87 * @param mixed
88 * @param string the cookie domain. Usually: .yourdomain.com
89 * @param string the cookie path
90 * @param string the cookie prefix
91 * @return void
92 */
93if ( ! function_exists('delete_cookie'))
94{
95 function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
96 {
97 set_cookie($name, '', '', $domain, $path, $prefix);
98 }
99}
100
101
102/* End of file cookie_helper.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +0000103/* Location: ./system/helpers/cookie_helper.php */