Ummm...that is VBScript, yes, but it is ASP code. *SERVER*-side code. Not code in the browser.
And you can *NOT* use document.getElementById( )
in ASP code.
If you need the cookie value in your ASP code, then you should stick to doing it this basic way. But instead do something like
Response.Cookies("firstname") = Trim(Request("keeper"))
where "keeper" is the *NAME* of a form field in the page as submitted to ASP.
However... With ASP code, you can *NOT* read the value of a cookie that was created or changed ON THE SAME PAGE.
In other words, in the code you show there, when you do
fname = Request.Cookies("firstname")
you would be getting the value of the cookie AS IT WAS WHEN THE PAGE WAS CALLED. The line above, where you set the cookie via Response.Cookies
would *NOT* affect the value you get from Request.Cookies.
This is different than in-browser code. Which makes sense: The value of a cookie *IS* a browser-side thing. If you change it in the browser, of course you can read it back immediately. But the ASP code won't change the value in the browser until the HTML generated by the ASP page is *sent* to the browser.
What I am REALLY curious about
: How can the cookie I store right this second affect what the "previous page" contained when I viewed it 10 minutes ago. Are you expecting cookies to implement some kind of time machine??