Source for file cookie_functions.php

Documentation is available at cookie_functions.php

  1. <?php
  2. /**
  3.  * CodeIgniter
  4.  *
  5.  * An open source application development framework for PHP 4.3.2 or newer
  6.  *
  7.  * @package        CodeIgniter
  8.  * @subpackage     Helpers
  9.  * @author        ExpressionEngine Dev Team
  10.  * @copyright    Copyright (c) 2006, EllisLab, Inc.
  11.  * @license        http://codeigniter.com/user_guide/license.html
  12.  * @link        http://codeigniter.com
  13.  * @since        Version 1.0
  14.  * @filesource
  15.  */
  16.  
  17. // ------------------------------------------------------------------------
  18.  
  19. /**
  20.  * CodeIgniter Cookie Helpers
  21.  *
  22.  * @author        ExpressionEngine Dev Team
  23.  * @link        http://codeigniter.com/user_guide/helpers/cookie_helper.html
  24.  */
  25.  
  26. // ------------------------------------------------------------------------
  27.  
  28. if (function_exists('set_cookie')) {
  29.     /**
  30.      * Set cookie
  31.      *
  32.      * Accepts six parameter, or you can submit an associative
  33.      * array in the first parameter containing all the values.
  34.      *
  35.      * @access    public
  36.      * @param    mixed 
  37.      * @param    string    the value of the cookie
  38.      * @param    string    the number of seconds until expiration
  39.      * @param    string    the cookie domain.  Usually:  .yourdomain.com
  40.      * @param    string    the cookie path
  41.      * @param    string    the cookie prefix
  42.      * @return    void 
  43.      */
  44.     function set_cookie($name ''$value ''$expire ''$domain ''$path '/'$prefix ''{
  45.         trigger_error('Función set_cookie() no implementada.'E_USER_ERROR);
  46.         
  47.         if (is_array($name))
  48.         {        
  49.             foreach (array('value''expire''domain''path''prefix''name'as $item)
  50.             {
  51.                 if (isset($name[$item]))
  52.                 {
  53.                     $$item $name[$item];
  54.                 }
  55.             }
  56.         }
  57.     
  58.         // Set the config file options
  59.         $CI =get_instance();
  60.     
  61.         if ($prefix == '' AND $CI->config->item('cookie_prefix'!= '')
  62.         {
  63.             $prefix $CI->config->item('cookie_prefix');
  64.         }
  65.         if ($domain == '' AND $CI->config->item('cookie_domain'!= '')
  66.         {
  67.             $domain $CI->config->item('cookie_domain');
  68.         }
  69.         if ($path == '/' AND $CI->config->item('cookie_path'!= '/')
  70.         {
  71.             $path $CI->config->item('cookie_path');
  72.         }
  73.         
  74.         if is_numeric($expire))
  75.         {
  76.             $expire time(86500;
  77.         }
  78.         else
  79.         {
  80.             if ($expire 0)
  81.             {
  82.                 $expire time($expire;
  83.             }
  84.             else
  85.             {
  86.                 $expire 0;
  87.             }
  88.         }
  89.     
  90.         setcookie($prefix.$name$value$expire$path$domain0);
  91.     }
  92. }
  93.     
  94. // --------------------------------------------------------------------
  95.  
  96. if (function_exists('get_cookie')) {
  97.     /**
  98.      * Fetch an item from the COOKIE array
  99.      *
  100.      * @access    public
  101.      * @param    string 
  102.      * @param    bool 
  103.      * @return    mixed 
  104.      */
  105.     function get_cookie($index ''$xss_clean FALSE{
  106.         trigger_error('Función get_cookie() no implementada.'E_USER_ERROR);
  107.         $CI =get_instance();
  108.         return $CI->input->cookie($index$xss_clean);
  109.     }
  110. }
  111.  
  112. // --------------------------------------------------------------------
  113.  
  114. if (function_exists('delete_cookie')) {
  115.     /**
  116.      * Delete a COOKIE
  117.      *
  118.      * @param    mixed 
  119.      * @param    string    the cookie domain.  Usually:  .yourdomain.com
  120.      * @param    string    the cookie path
  121.      * @param    string    the cookie prefix
  122.      * @return    void 
  123.      */
  124.     function delete_cookie($name ''$domain ''$path '/'$prefix ''{
  125.         trigger_error('Función delete_cookie() no implementada.'E_USER_ERROR);
  126.         set_cookie($name''''$domain$path$prefix);
  127.     }
  128. }
  129.  
  130. ?>

Documentation generated on Tue, 22 Nov 2011 13:28:51 -0200 by phpDocumentor 1.4.3