Source for file cookie.php

Documentation is available at cookie.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Input
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Joomla! Input Cookie Class
  14.  *
  15.  * @package     Joomla.Platform
  16.  * @subpackage  Input
  17.  * @since       11.1
  18.  */
  19. class JInputCookie extends JInput
  20. {
  21.     /**
  22.      * Constructor.
  23.      *
  24.      * @param   array  $source   Ignored.
  25.      * @param   array  $options  Array of configuration parameters (Optional)
  26.      *
  27.      * @since   11.1
  28.      */
  29.     public function __construct(array $source nullarray $options array())
  30.     {
  31.         if (isset($options['filter']))
  32.         {
  33.             $this->filter = $options['filter'];
  34.         }
  35.         else
  36.         {
  37.             $this->filter = JFilterInput::getInstance();
  38.         }
  39.  
  40.         // Set the data source.
  41.         $this->data = $_COOKIE;
  42.  
  43.         // Set the options for the class.
  44.         $this->options = $options;
  45.     }
  46.  
  47.     /**
  48.      * Sets a value
  49.      *
  50.      * @param   string   $name      Name of the value to set.
  51.      * @param   mixed    $value     Value to assign to the input.
  52.      * @param   integer  $expire    The time the cookie expires. This is a Unix timestamp so is in number
  53.      *                               of seconds since the epoch. In other words, you'll most likely set this
  54.      *                               with the time() function plus the number of seconds before you want it
  55.      *                               to expire. Or you might use mktime(). time()+60*60*24*30 will set the
  56.      *                               cookie to expire in 30 days. If set to 0, or omitted, the cookie will
  57.      *                               expire at the end of the session (when the browser closes).
  58.      * @param   string   $path      The path on the server in which the cookie will be available on. If set
  59.      *                               to '/', the cookie will be available within the entire domain. If set to
  60.      *                               '/foo/', the cookie will only be available within the /foo/ directory and
  61.      *                               all sub-directories such as /foo/bar/ of domain. The default value is the
  62.      *                               current directory that the cookie is being set in.
  63.      * @param   string   $domain    The domain that the cookie is available to. To make the cookie available
  64.      *                               on all subdomains of example.com (including example.com itself) then you'd
  65.      *                               set it to '.example.com'. Although some browsers will accept cookies without
  66.      *                               the initial ., RFC 2109 requires it to be included. Setting the domain to
  67.      *                               'www.example.com' or '.www.example.com' will make the cookie only available
  68.      *                               in the www subdomain.
  69.      * @param   boolean  $secure    Indicates that the cookie should only be transmitted over a secure HTTPS
  70.      *                               connection from the client. When set to TRUE, the cookie will only be set
  71.      *                               if a secure connection exists. On the server-side, it's on the programmer
  72.      *                               to send this kind of cookie only on secure connection (e.g. with respect
  73.      *                               to $_SERVER["HTTPS"]).
  74.      * @param   boolean  $httpOnly  When TRUE the cookie will be made accessible only through the HTTP protocol.
  75.      *                               This means that the cookie won't be accessible by scripting languages, such
  76.      *                               as JavaScript. This setting can effectively help to reduce identity theft
  77.      *                               through XSS attacks (although it is not supported by all browsers).
  78.      *
  79.      * @return  void 
  80.      *
  81.      * @link    http://www.ietf.org/rfc/rfc2109.txt
  82.      * @see     setcookie()
  83.      * @since   11.1
  84.      */
  85.     public function set($name$value$expire 0$path ''$domain ''$secure false$httpOnly false)
  86.     {
  87.         setcookie($name$value$expire$path$domain$secure$httpOnly);
  88.  
  89.         $this->data[$name$value;
  90.     }
  91. }

Documentation generated on Tue, 19 Nov 2013 14:57:34 +0100 by phpDocumentor 1.4.3