Andrey Andreev | dbf4a5a | 2012-03-13 12:08:59 +0200 | [diff] [blame^] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | dbf4a5a | 2012-03-13 12:08:59 +0200 | [diff] [blame^] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | dbf4a5a | 2012-03-13 12:08:59 +0200 | [diff] [blame^] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
| 27 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 28 | /** |
| 29 | * CodeIgniter Cookie Helpers |
| 30 | * |
| 31 | * @package CodeIgniter |
| 32 | * @subpackage Helpers |
| 33 | * @category Helpers |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 34 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 35 | * @link http://codeigniter.com/user_guide/helpers/cookie_helper.html |
| 36 | */ |
| 37 | |
| 38 | // ------------------------------------------------------------------------ |
| 39 | |
| 40 | /** |
| 41 | * Set cookie |
| 42 | * |
| 43 | * Accepts six parameter, or you can submit an associative |
| 44 | * array in the first parameter containing all the values. |
| 45 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 46 | * @param mixed |
| 47 | * @param string the value of the cookie |
| 48 | * @param string the number of seconds until expiration |
Derek Jones | 37f4b9c | 2011-07-01 17:56:50 -0500 | [diff] [blame] | 49 | * @param string the cookie domain. Usually: .yourdomain.com |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 50 | * @param string the cookie path |
| 51 | * @param string the cookie prefix |
| 52 | * @return void |
| 53 | */ |
| 54 | if ( ! function_exists('set_cookie')) |
| 55 | { |
Phil Sturgeon | d8d1e24 | 2011-02-16 17:23:16 +0000 | [diff] [blame] | 56 | function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 57 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 58 | // Set the config file options |
| 59 | $CI =& get_instance(); |
Phil Sturgeon | d8d1e24 | 2011-02-16 17:23:16 +0000 | [diff] [blame] | 60 | $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 61 | } |
| 62 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 63 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 64 | // -------------------------------------------------------------------- |
| 65 | |
| 66 | /** |
| 67 | * Fetch an item from the COOKIE array |
| 68 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 69 | * @param string |
| 70 | * @param bool |
| 71 | * @return mixed |
| 72 | */ |
| 73 | if ( ! function_exists('get_cookie')) |
| 74 | { |
| 75 | function get_cookie($index = '', $xss_clean = FALSE) |
| 76 | { |
Derek Jones | a04cfa7 | 2009-02-10 20:16:57 +0000 | [diff] [blame] | 77 | $CI =& get_instance(); |
Andrey Andreev | dbf4a5a | 2012-03-13 12:08:59 +0200 | [diff] [blame^] | 78 | $prefix = isset($_COOKIE[$index]) ? '' : config_item('cookie_prefix'); |
Derek Jones | 2c8dc58 | 2009-02-10 20:15:49 +0000 | [diff] [blame] | 79 | return $CI->input->cookie($prefix.$index, $xss_clean); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
| 83 | // -------------------------------------------------------------------- |
| 84 | |
| 85 | /** |
| 86 | * Delete a COOKIE |
| 87 | * |
| 88 | * @param mixed |
Andrey Andreev | dbf4a5a | 2012-03-13 12:08:59 +0200 | [diff] [blame^] | 89 | * @param string the cookie domain. Usually: .yourdomain.com |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 90 | * @param string the cookie path |
| 91 | * @param string the cookie prefix |
| 92 | * @return void |
| 93 | */ |
| 94 | if ( ! function_exists('delete_cookie')) |
| 95 | { |
| 96 | function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '') |
| 97 | { |
| 98 | set_cookie($name, '', '', $domain, $path, $prefix); |
| 99 | } |
| 100 | } |
| 101 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 102 | /* End of file cookie_helper.php */ |
Andrey Andreev | dbf4a5a | 2012-03-13 12:08:59 +0200 | [diff] [blame^] | 103 | /* Location: ./system/helpers/cookie_helper.php */ |