<?php
// 保持会话($_SESSION)
session_start();

$randStr = function () {
    return substr(md5(uniqid(rand())), 16);
};

function Encrypt($data, $key, $iv)
{
    // OPENSSL_RAW_DATA 不进行 base64 编码
    $ciphertext = openssl_encrypt($data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv);
    echo bin2hex($ciphertext);
}

function Decrypt($data, $key, $iv)
{
    $plaintext = openssl_decrypt(base64_decode($data), "aes-128-cbc", $key, OPENSSL_RAW_DATA, $iv);
    echo $plaintext;
}

if (isset($_GET["cookie"]))
{
    // $_SESSION 跨函数
    $_SESSION["iv"] = $randStr();
    $_SESSION["key"] = $randStr();

    setcookie("uid", $_SESSION["key"], time() + 120);    // 120s 后过期
    setcookie("vid", $_SESSION["iv"], time() + 120);     // 120s 后过期
} else {
    $content = file_get_contents("php://input");
    // 解析字符串(适合 POST 请求 key=value)
    $data = array();
    parse_str($content, $data);
    var_dump($data);

    // extract - 将变量从数组中导入到当前的符号表中
    extract($data, EXTR_PREFIX_SAME, "var_");

    echo $cmd;

    $key = $_SESSION["key"];
    echo $key;
}

?>


curl -s -v --cookie "uid=670fe5af5a4c61be;vid=de4282eb4ac44703" -X POST -H "Content-Type: application/x-www-data-urlencoded" http://127.0.0.1:8087/done.php -d "cmd=1234"

报错：
PHP Warning:  Undefined array key "key" in /root/tmp/webshell/done.php on line 34