<?php
function get_cookie($header=0)
{
if ($header == '' || empty($header)) {
return false;
}
$preg = '/Set-Cookie:\ (.*?);/';
preg_match_all($preg, $header, $result);
$arr = $result[1];
$cookie = '';
for ($i = 0;$i < count($arr);$i++) {
$cookie .= $arr[$i].';';
}
return $cookie;
}
<?php
$header = <<<EOF
HTTP/1.1 200 OK
Server: Tengine
Date: Tue, 31 Aug 2021 14:51:14 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 45
Connection: keep-alive
Set-Cookie: JSESSIONID=48A4257DBCEA2E9B76E116BA913114CA; Path=/; HttpOnly
Set-Cookie: lv=2; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: fid=1619; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: _uid=154982959; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: uf=b2d2c93beefa90dceea3c95dda94cdc00123b53c040590ba299b772214c809c58bf65abbd4c55c90500603c0fa2bd44b913b662843f1f4ad6d92e371d7fdf6443b938441de6193ed102289339c6dea125558ebfe920d455c3ad9647fd48a5737cdf3e8140a85141b; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: _d=1630421474065; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: UID=154982959; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: vc=A2A5F4EB9D286F1CFF041FBD5586301E; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/; HttpOnly
Set-Cookie: vc2=90A2890B9BA7075FBEEC4A2C0A37408D; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/; HttpOnly
Set-Cookie: vc3=PtcThQ83luT2yII0pOKXhZqXKG4Hos5sNovInS%2Bh1HgWek1l9jEWHHlq5zm71T4C3S%2BWjLesZ2q0f8SBR66MTNKrctnrQ%2FOxoUI8eRJEK1o%2FDs2iykW9sTf1KVuKCeiS4rlRM7dtGo5YEEptsRn9nZy8YeL3ravuuO5LEWlgQlI%3D934fc28957b2c2ef46257a1d0028bf03; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/; HttpOnly
Set-Cookie: xxtenc=03a365813a2ee579cc07b46e93f574ec; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: DSSTASH_LOG=C_38-UN_1652-US_154982959-T_1630421474067; Domain=.chaoxing.com; Expires=Thu, 30-Sep-2021 14:51:14 GMT; Path=/
Set-Cookie: route=2751c02f853f6479988f0b3d8a5cb9ce;Path=/
EOF;
echo get_cookie($header);
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。