SOURCE

function getCookie(cookie, name) {
    var tmp, reg = new RegExp("(^|)"+ name +"=([^;]*)(;|$)");
    tmp = reg.exec(cookie)
    if (tmp){
        return (tmp[2]);
    } else {
        return null;
    }
};
let str = "PHPSESSID=vg5eteufjknonqm9gs9ghir0ef; expires=Fri, 04-Nov-2022 05:04:22 GMT; Max-Age=54000; path=/,tz_session_id=6363ca66602c855344; expires=Fri, 04-Nov-2022 02:04:22 GMT; Max-Age=43200; path=/; domain=.wtuan.top,tz_session_id_ttl=1667527462; expires=Fri, 04-Nov-2022 02:04:22 GMT; Max-Age=43200; path=/; domain=.wtuan.top"
let res = getCookie(str,'PHPSESSID')
console.log(res)
console 命令行工具 X clear

                    
>
console