<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Cookie Helpers
* CI cookie帮助
* @package CodeIgniter
* @subpackage Helpers
* @category Helpers
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/helpers/cookie_helper.html
*/
// ------------------------------------------------------------------------
/**
* Set cookie
* 设置cookie
*
* Accepts six parameter, or you can submit an associative
* array in the first parameter containing all the values.
* 接受六个参数,也可以提交关联
* 的第一个参数的数组中包含的所有值。
* @access public
* @param mixed
* @param string the value of the cookie cookie值
* @param string the number of seconds until expiration 直到过期的秒数
* @param string the cookie domain. Usually: .yourdomain.com 作用域
* @param string the cookie path 保存的路径
* @param string the cookie prefix 串的cookie前缀
* @return void
*/
if ( ! function_exists('set_cookie'))
{
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
// Set the config file options 设置配置文件选项
$CI =& get_instance();
$CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
}
}
// --------------------------------------------------------------------
/**
* Fetch an item from the COOKIE array
* 取一个项目从COOKIE数组
* @access public
* @param string
* @param bool
* @return mixed
*/
if ( ! function_exists('get_cookie'))
{
function get_cookie($index = '', $xss_clean = FALSE)
{
$CI =& get_instance();
$prefix = '';
//如果在$_cookie中没有找到需要的索引值,并且cookie的前缀不为空,那么先取得cookie的前缀
if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
{
$prefix = config_item('cookie_prefix');
}
//从input中取得cookie的值
return $CI->input->cookie($prefix.$index, $xss_clean);
}
}
// --------------------------------------------------------------------
/**
* Delete a COOKIE
* 删除cookie的值
* @param mixed 名称
* @param string the cookie domain. Usually: .yourdomain.com 作用域
* @param string the cookie path 路径
* @param string the cookie prefix 前缀
* @return void
*/
if ( ! function_exists('delete_cookie'))
{
function delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
{
set_cookie($name, '', '', $domain, $path, $prefix);
}
}
/* End of file cookie_helper.php */
/* Location: ./system/helpers/cookie_helper.php */