I am currently logged in with my browser and wanted to get the current cookie of that session. but when i use this code it creates another session id for that request only. NOT for the currently logged in session in my browser.
$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)"
}
i wanted to output the similar session id cookie in my browser and with the script.