Re: Non persistent cookie timeout?
- From: "S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com>
- Date: Wed, 11 Jan 2006 21:07:34 -0600
Belle,
Just after you create your cooke and before you add it to the response use
authCookie.Expires = DateTime.Now.AddMinutes(10);
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
<bashful.belle@xxxxxxxxx> wrote in message
news:1137033448.646948.236000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> I'm using Forms authentication and a non persistent cookie in my
> asp.net application.
> How do i get the cookie to time out after a period of inactivity, say
> 10 minutes, and force the user to login again?
> If I close the browser, the next time I use the application, it makes
> me log in - and That's fine.
> However if I keep the browser session open, it keeps my login valid for
> as long as the browser is open - I want it to time out.
> Specifying the timeout value in the web.config seems to have no effect.
> any pointers? Code appended. Thanks!
>
> <authentication mode="Forms">
> <forms loginUrl="logon.aspx" name = "portal" timeout="10"
> slidingExpiration="true" protection="All" path="/">
> </forms>
> </authentication>
>
>
> // Create the authetication ticket
> FormsAuthenticationTicket authTicket = new
> FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now,
> DateTime.Now.AddMinutes(10),false, "");
>
> // Now encrypt the ticket.
> string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
>
> // Create a cookie and add the encrypted ticket
> HttpCookie authCookie = new
> HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
>
> // Add the cookie to the outgoing cookies collection.
> Response.Cookies.Add(authCookie);
> Session.Add("Login", txtUserName.Text);
> Session.Add("Group",Group);
>
> Page.SmartNavigation = false;
> //Redirect the user to the originally requested page
> Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUserName.Text,false));
>
.
- Follow-Ups:
- Re: Non persistent cookie timeout?
- From: bashful . belle
- Re: Non persistent cookie timeout?
- References:
- Non persistent cookie timeout?
- From: bashful . belle
- Non persistent cookie timeout?
- Prev by Date: Re: Timer Not Working - Can Anyone Explain Why and How to fix?
- Next by Date: Re: Query data from multiple tables and saving back
- Previous by thread: Non persistent cookie timeout?
- Next by thread: Re: Non persistent cookie timeout?
- Index(es):
Relevant Pages
|