FormsAuth Ticket Keeps Expiring

Discussion in 'ASP .Net Security' started by George Durzi, Sep 18, 2003.

  1. George Durzi

    George Durzi Guest

    Calling out ASP.NET Forms Auth Experts! I need your help.

    Using FormsAuthentication to auth against Active Directory. During my login
    process, I'm constructing a FormsAuthenticationTicket as follows:

    FormsAuthenticationTicket oAuthTicket = new FormsAuthenticationTicket(1,
    txtUserName.Value.Trim(), DateTime.Now, DateTime.Now.AddHours(8), true,
    sGroups);

    Where:
    - 1 is the version
    - txtUserName.Value.Trim() holds the user name from the login screen
    - DateTime.Now is the issue Date
    - DateTime.Now.AddHours(8) is the expiration date
    - true designates persistence
    - sGroups is a "|" character separated string of groups of which the user is
    a member of

    I then encrypt the AuthenticationTicket then add it to the cookies
    collection
    string sTicket = FormsAuthentication.Encrypt(oAuthTicket);
    HttpCookie oCookie = new HttpCookie(FormsAuthentication.FormsCookieName,
    sTicket);
    Response.Cookies.Add(oCookie);

    In web.config, I also have the timeout set to 480 minutes. This overrides
    whatever is set in machine.config.
    <authentication mode="Forms">
    <forms loginUrl="login.aspx" name="adAuthCookie" timeout="480" path="/"
    />
    </authentication>

    The problem is the users keep getting kicked out to the login screen in much
    less than the set time of 480 minutes. I'm not deploying any updates to the
    application during that time, so the Sessions aren't being reset, which I
    know would cause the user to get kicked out.

    Interesting thing though, when I do an oCookie.Expires, it gives me
    01/01/2001, so the Expires property isn't being carried from the
    FormsAuthenticationTicket.

    However, the value of adAuthTicket.Expiration is always correct. (I'm
    sticking it in a session for testing)



    Can anyone explain this behaviour?
     
    George Durzi, Sep 18, 2003
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    HELP: Cookie keeps expiring!

    VB Programmer, Nov 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    444
    VB Programmer
    Nov 3, 2003
  2. chongo
    Replies:
    1
    Views:
    497
    Trent Millar
    Apr 28, 2004
  3. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Two Different FormsAuth Logins for Same Application

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Sep 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    380
    Walter Wang [MSFT]
    Sep 11, 2006
  4. tparks69

    forms based authentication - ticket not expiring

    tparks69, Jan 31, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    194
    tparks69
    Jan 31, 2005
  5. authentication ticket expiring too soon

    , Sep 27, 2006, in forum: ASP .Net Security
    Replies:
    2
    Views:
    376
Loading...

Share This Page