PageRenderTime 51ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/joomla/libraries/fof/input/jinput/cookie.php

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