Re: Persist login does not work

From: Eric Marvets (ericm_at_bangproject.com)
Date: 05/23/04


Date: Sun, 23 May 2004 15:23:45 -0400

Do this:

<existing code>

// Create a cookie and add the encrypted ticket to the cookie as data.
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName,
encryptedTicket);

</existing code>

<add>

authCookie.Expires = DateTime.Now.AddMinutes(60);

</add>

<existing code>

// Add the cookie to the outgoing cookies collection.
Response.Cookies.Add(authCookie);

</existing code>

Then in the Application_AuthenticateRequest event, after you finish
extracting the roles, reset the exipration of the Cookie and replace it in
the Response.

-- 
Eric Marvets
Principal Consultant
the bang project
<shameless self promotion>
Email sales@bangproject.com for Information on Our Architecture and
Mentoring Services
</shameless self promotion>


Relevant Pages

  • Re: Custom Authentication
    ... The FormAuthentication class is the one that creates the encrypted ticket in ... "logs" them in by providing the secure cookie ... FormsAuthentication ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session expiration and authentication
    ... The user has to be at the site, because when you call SignOut, it has to be ... able to clear the cookie on the client. ... the bang project <shameless self promotion> ...
    (microsoft.public.dotnet.framework.aspnet.security)