Hi,
Don't know exactly for ASP.NET but in ASP, cookies must be written
before anything else HTML coding. With the Page_Unload event, I'm assuming
that all of your HTML page has been written to the client and made visible
to him. Obviously, it's way too late to write cookie at this time on the
server side when the page has been made visible to client side.
Also, with ASP and probably ASP.NET, the web server give you access to a
Session state, wich is probably a better choice for doing what you want than
trying to work out your own time-out cookies.
S. L.
"Rich" <> wrote in message
news:13e9101c3f7fc$7aa74e30$...
> Hello,
>
> I want to create a cookie that will expire in a few
> mintues after a user leaves my page so that they can
> return without having to login again if they were only
> gone for a few minutes. I tried putting this code in the
> Page_Unload event but got an error message that cookies
> not supported here.
> ...
> Sub Page_Unload 'this not working here
> Dim objCookie As HttpCookie
> objCookie = New HttpCookie("mycookie", "cookie1")
> objCookie.expires = DateTime.Now.AddMinutes(2)
> Response.Cookies.Add( objCookie )
> End Sub
> </script>
>
> What is the best place to create a cookie that will only
> last for a few mintues after leaving a page
>
> Thanks,
> Rich
|