problem with slidingExpiration

From: Alessandro Zucchi (Zucchi_at_discussions.microsoft.com)
Date: 03/04/05

  • Next message: Joe Kaplan \(MVP - ADSI\): "Re: How To:Windows Integrated Security and workgroups"
    Date: Fri, 4 Mar 2005 08:47:05 -0800
    
    

    Hi all,
    I'm trying to use Forms authentication with slidingExpiration option set to
    true since I want permit users to stay logged in when they use the web
    application. Only idle timeout must logged out the users.

    ***********************************************************
    Follow the code:

    string CF="ZCCLSN70R21C816A";
    int expiration=2;
    DateTime dt= DateTime.Now;
    DateTime dte=dt.AddMinutes(expiration);
    FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(CF,false,
    expiration);
                            
    //cripto l'authentication ticket
    string cookiestr = FormsAuthentication.Encrypt(tkt);
    //creo il cookie
    HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName,
    cookiestr);
    //aggiungo il cookie
    //ck.Expires=tkt.Expiration;
    Response.Cookies.Set(ck);

    ***********************************************
    Follow Web.config
     <!--Pagina di login-->
        <authentication mode="Forms">
                    <forms loginUrl="login.aspx" name="miocook" protection="All" path="./"
    timeout="2" slidingExpiration="true" />
    </authentication>

     <authorization>
                    <deny users ="?" />
                    <allow users = "*" />
    </authorization>

    <sessionState
                mode="StateServer"
                stateConnectionString="tcpip=127.0.0.1:42424"
                sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
                cookieless="false"
                timeout="30"
    />
    **********************************************************
    The problem is that after 2 minutes, also if I use the application, the
    cookie expire.
    It look to me that the flag slidingExpiration has no effect.

    Anyone can help me ?
    By


  • Next message: Joe Kaplan \(MVP - ADSI\): "Re: How To:Windows Integrated Security and workgroups"

    Relevant Pages

    • Re: problem with slidingExpiration
      ... > true since I want permit users to stay logged in when they use the web ... > DateTime dt= DateTime.Now; ... > string cookiestr = FormsAuthentication.Encrypt; ... > //aggiungo il cookie ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: problem with slidingExpiration
      ... DateTime dt= DateTime.Now; ... //cripto l'authentication ticket ... string cookiestr = FormsAuthentication.Encrypt; ... //aggiungo il cookie ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Do I need to delete my cookie before re-adding it?
      ... a cookie that expires in 1 day. ... Before adding the cookie each time, do I need to delete the previous cookie? ... Dim objCookie As HttpCookie ... Dim dt As DateTime = DateTime.Now ...
      (microsoft.public.dotnet.framework.aspnet)
    • cookie expiry date problem
      ... Below is the code to save the cookie and set the expiry date of the cookie ... DateTime dt = DateTime.Now; ... TimeSpan ts = new TimeSpan; ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • cookie expiry date 01/01/0001
      ... Below is the code to save the cookie and set the expiry date of the cookie ... DateTime dt = DateTime.Now; ... TimeSpan ts = new TimeSpan; ...
      (microsoft.public.dotnet.general)

  • Quantcast