N
N
Netnamee2019-01-26 10:57:58
PHP
Netnamee, 2019-01-26 10:57:58

Converting to PHP array?

You need this:

Transfer-Encoding: chunked
HTTP/1.1 200 OK
Server: nginx
Connection: keep-alive
Set-Cookie: test=asd; expires=Wed, 16-Jan-2019 07:50:54 GMT; path=/; domain=test.tssaltan.ru; httponly
Set-Cookie: test=asd; expires=Tue, 05-Feb-2019 07:50:54 GMT; path=/; domain=localhost; httponly
Set-Cookie: hello=world_832; expires=Tue, 05-Feb-2019 07:50:54 GMT
Set-Cookie: name=random_5c4c115ea048f; expires=Tue, 05-Feb-2019 07:50:54 GMT
Date: Sat, 26 Jan 2019 07:50:54 GMT
Content-Type: text/html; charset=UTF-8

Cookies send!

Convert to json array
{"test.tssaltan.ru":{"hello":{"value":"world_832","expires":1.549353054E9},"name":{"value":"random_5c4c115ea048f","expires":1.549353054E9}},"localhost":{"test":{"value":"asd","expires":1.549353054E9}}}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Georgy Baruchyan, 2019-01-26
@Snatch87

json_decode
UPD:
Apparently I misunderstood the question. Try like this
json_encode(['test.tssaltan.ru' => $_COOKIE]);

K
Kirill Mokevnin, 2019-01-26
@toxicmt

First parse php.net/manual/fa/function.http-parse-headers.php then convert to desired structure and json_encode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question