Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 1 | <?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 Jones | 7f3719f | 2010-01-05 13:35:37 +0000 | [diff] [blame] | 9 | * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 10 | * @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 | */ |
| 45 | if ( ! function_exists('set_cookie')) |
| 46 | { |
| 47 | function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '') |
| 48 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 49 | // Set the config file options |
| 50 | $CI =& get_instance(); |
Derek Jones | 22224b5 | 2010-03-02 23:06:53 -0600 | [diff] [blame] | 51 | $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 52 | } |
| 53 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame^] | 54 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 55 | // -------------------------------------------------------------------- |
| 56 | |
| 57 | /** |
| 58 | * Fetch an item from the COOKIE array |
| 59 | * |
| 60 | * @access public |
| 61 | * @param string |
| 62 | * @param bool |
| 63 | * @return mixed |
| 64 | */ |
| 65 | if ( ! function_exists('get_cookie')) |
| 66 | { |
| 67 | function get_cookie($index = '', $xss_clean = FALSE) |
| 68 | { |
Derek Jones | a04cfa7 | 2009-02-10 20:16:57 +0000 | [diff] [blame] | 69 | $CI =& get_instance(); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame^] | 70 | |
Derek Jones | 2c8dc58 | 2009-02-10 20:15:49 +0000 | [diff] [blame] | 71 | $prefix = ''; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame^] | 72 | |
Derek Jones | 2c8dc58 | 2009-02-10 20:15:49 +0000 | [diff] [blame] | 73 | if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '') |
| 74 | { |
| 75 | $prefix = config_item('cookie_prefix'); |
| 76 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame^] | 77 | |
Derek Jones | 2c8dc58 | 2009-02-10 20:15:49 +0000 | [diff] [blame] | 78 | return $CI->input->cookie($prefix.$index, $xss_clean); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 79 | } |
| 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 | */ |
| 93 | if ( ! 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 Jones | a3ffbbb | 2008-05-11 18:18:29 +0000 | [diff] [blame] | 103 | /* Location: ./system/helpers/cookie_helper.php */ |