Create cookie in what event when leaving page?

R

Rich

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 in aspx, where
this is supported, that will only last for a few mintues
after leaving a page

Thanks,
Rich
 
B

bruce barker

page_unload fires after the page has been rendered, do it in page_load

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top