1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 4.3.2 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2009, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
19 * CodeIgniter Cookie Helpers
21 * @package CodeIgniter
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/helpers/cookie_helper.html
28 // ------------------------------------------------------------------------
33 * Accepts six parameter, or you can submit an associative
34 * array in the first parameter containing all the values.
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
45 if ( ! function_exists('set_cookie'))
47 function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
51 foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
53 if (isset($name[$item]))
55 $$item = $name[$item];
60 // Set the config file options
61 $CI =& get_instance();
63 if ($prefix == '' AND $CI->config->item('cookie_prefix') != '')
65 $prefix = $CI->config->item('cookie_prefix');
67 if ($domain == '' AND $CI->config->item('cookie_domain') != '')
69 $domain = $CI->config->item('cookie_domain');
71 if ($path == '/' AND $CI->config->item('cookie_path') != '/')
73 $path = $CI->config->item('cookie_path');
76 if ( ! is_numeric($expire))
78 $expire = time() - 86500;
84 $expire = time() + $expire;
92 setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
96 // --------------------------------------------------------------------
99 * Fetch an item from the COOKIE array
106 if ( ! function_exists('get_cookie'))
108 function get_cookie($index = '', $xss_clean = FALSE)
110 $CI =& get_instance();
114 if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
116 $prefix = config_item('cookie_prefix');
119 return $CI->input->cookie($prefix.$index, $xss_clean);
123 // --------------------------------------------------------------------
129 * @param string the cookie domain. Usually: .yourdomain.com
130 * @param string the cookie path
131 * @param string the cookie prefix
134 if ( ! function_exists('delete_cookie'))
136 function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
138 set_cookie($name, '', '', $domain, $path, $prefix);
143 /* End of file cookie_helper.php */
144 /* Location: ./system/helpers/cookie_helper.php */