1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
httpcookies.php
См. документацию.
1<?php
2
9
10namespace Bitrix\Main\Web;
11
12use Bitrix\Main\ArgumentTypeException;
13
18{
22 public function __construct(array $values = null)
23 {
24 if ($values !== null)
25 {
26 foreach ($values as $key => $value)
27 {
28 if (!($value instanceof Http\Cookie))
29 {
30 $value = new Http\Cookie($key, $value);
31 }
32 $this[$key] = $value;
33 }
34 }
35 }
36
41 public function implode(): string
42 {
43 $str = '';
44 foreach ($this->values as $cookie)
45 {
46 $str .= ($str == '' ? '' : '; ') . rawurlencode($cookie->getName()) . '=' . rawurlencode($cookie->getValue());
47 }
48
49 return $str;
50 }
51
52 public function addFromString(string $str): void
53 {
54 if (($pos = strpos($str, ';')) !== false && $pos > 0)
55 {
56 $cookie = trim(substr($str, 0, $pos));
57 }
58 else
59 {
60 $cookie = trim($str);
61 }
62 $cookies = explode('=', $cookie, 2);
63
64 $name = rawurldecode($cookies[0]);
65 $value = rawurldecode($cookies[1]);
66
67 // TODO: a cookie has more attributes
68 $this[$name] = new Http\Cookie($name, $value);
69 }
70
71 public function toArray()
72 {
73 $cookies = [];
74 foreach ($this->values as $cookie)
75 {
76 $cookies[$cookie->getName()] = $cookie->getValue();
77 }
78
79 return $cookies;
80 }
81
82 #[\ReturnTypeWillChange]
83 public function offsetSet($offset, $value)
84 {
85 if (!($value instanceof Http\Cookie))
86 {
87 throw new ArgumentTypeException('value', Http\Cookie::class);
88 }
89 parent::offsetSet($offset, $value);
90 }
91}
__construct(array $values=null)
Определения httpcookies.php:22
addFromString(string $str)
Определения httpcookies.php:52
offsetSet($offset, $value)
Определения httpcookies.php:83
$str
Определения commerceml2.php:63
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
if(empty($signedUserToken)) $key
Определения quickway.php:257