我目前使用浏览器登录并想获取该会话的当前 cookie。但是当我使用此代码时,它只会为该请求创建另一个会话 ID。不适用于我浏览器中当前登录的会话。
$url = "http://example.website/"
$cookiejar = New-Object System.Net.CookieContainer
$webrequest = [System.Net.HTTPWebRequest]::Create($url);
$webrequest.CookieContainer = $cookiejar
$response = $webrequest.GetResponse()
$cookies = $cookiejar.GetCookies($url)
foreach ($cookie in $cookies) {
Write-Host "$($cookie.name) = $($cookie.value)"
}
我想在我的浏览器和脚本中输出类似的会话 id cookie。