asp.net cookie timeout

K

krithika.sridhar

I want my asp.net application to create a non persisitent cookie that
will timeout after 20 minutes.

I want the cookie to expire when the bowser is closed AND timeout if
the user has been inactive (sliding expiration)

How can I accomplish this?
If i set the expiration time on the cookie, it ceases to be non
persistent, and the user stays logged in if the browser was closed and
re-opened in under 20 minutes.

Thanks.
 
S

S. Justin Gengo [MCP]

Sridhar,

I just answered the same questions for Belle below...

MyCookie.Expires = Now.Add.Minutes(20)

And then make certain to use the forms authentication object's redirect:

FormsAuthentication.RedirectFromLoginPage(username.Text, false)

Setting the second parameter lets you specify if a cookie is persistent.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

I'm not totally sure on this, but I believe you are asking too much of the
HTTP cookie specification.
Peter
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top