blob: 7cee02827c1b691815136837e4978d63747f0833 [file] [log] [blame]
Derek Jones4b9c6292011-07-01 17:40:48 -05001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Greg Aker0711dc82011-01-05 10:49:40 -06009 * @copyright Copyright (c) 2008 - 2011, 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
Derek Jones4b9c6292011-07-01 17:40:48 -050040 * @param string the cookie domain. Usually: .yourdomain.com
Derek Allard2067d1a2008-11-13 22:59:24 +000041 * @param string the cookie path
42 * @param string the cookie prefix
43 * @return void
44 */
45if ( ! function_exists('set_cookie'))
46{
Phil Sturgeond8d1e242011-02-16 17:23:16 +000047 function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +000048 {
Derek Allard2067d1a2008-11-13 22:59:24 +000049 // Set the config file options
50 $CI =& get_instance();
Phil Sturgeond8d1e242011-02-16 17:23:16 +000051 $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
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
Derek Jones4b9c6292011-07-01 17:40:48 -050088 * @param string the cookie domain. Usually: .yourdomain.com
Derek Allard2067d1a2008-11-13 22:59:24 +000089 * @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 */