Interacting With Cookies From PowerShell ASP

PowerShell ASP works in much the same way that ASP.NET would. Interacting with cookies is no different. Below is an example showing how to display and create cookies in the user's browser:

        <link href="stylesheet.css" rel="stylesheet" type="text/css"></link>
        if($Request.RequestType -eq "POST")
          #Check the cookies in the request.
          $Request.Cookies.AllKeys | % { echo "$_ : $($Request.Cookies[$_].Value)<br>" }
          #Create a cookie
          $cookie = New-Object -TypeName System.Web.HttpCookie -ArgumentList @("myCookie","myCookieValue")
          #Add it to the cookies collection in the response
          <form action="" method="POST">
            <button name="seeCookies" value="seeCookies">Check Cookies.</button>

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at