formsauthentication

Discussion in 'ASP .Net' started by Grant Merwitz, Mar 2, 2005.

  1. Hi, i am using forms authentication in an ASP.NET project

    I am setting the Forms authentication cookie by using:
    FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);

    Now when i review my trace on my page, there are two cookies created that
    look identical.
    When i FormsAuthentication.SignOut() they both dissappear.

    Any ideas as to why two cookies are created?

    TIA
    Grant Merwitz, Mar 2, 2005
    #1
    1. Advertising

  2. Grant Merwitz

    Janaka Guest

    Grant,

    Is this a local app you are debugging or on the live server? Try setting
    the domain property of the cookie. That may clear up the double cookie
    problem.

    Janaka

    "Grant Merwitz" <> wrote in message
    news:%...
    > Hi, i am using forms authentication in an ASP.NET project
    >
    > I am setting the Forms authentication cookie by using:
    > FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
    >
    > Now when i review my trace on my page, there are two cookies created that
    > look identical.
    > When i FormsAuthentication.SignOut() they both dissappear.
    >
    > Any ideas as to why two cookies are created?
    >
    > TIA
    >
    >
    >
    Janaka, Mar 2, 2005
    #2
    1. Advertising

  3. Grant Merwitz

    Janaka Guest

    Try setting it this way: I've set the cookie to timeout after 20 minutes
    but you can change this

    FormsAuthenticationTicket authTicket = new
    FormsAuthenticationTicket(tbUserName.Text, false, 20);

    // Encrypt and store the ticket

    string encryptTicket = FormsAuthentication.Encrypt(authTicket);

    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName,
    encryptTicket);

    authCookie.Domain = ConfigurationSettings.AppSettings["domain"];

    // Redirect

    Response.Cookies.Add(authCookie);

    Response.Redirect(FormsAuthentication.GetRedirectUrl(tbUserName.Text,
    false));


    "Grant Merwitz" <> wrote in message
    news:...
    > how do you set the domain of a FormsAuthentication Cookie?
    >
    > Currently the only method i'm calling is:
    > FormsAuthentication.RedirectFromLoginPage(tbUserName.Text, false);
    >
    > I can't find any FormsAuthentication.Domain or anything like that
    > The only other thing i can see is an overload for 'RedirectFromLoginPage':
    > public static void RedirectFromLoginPage(
    > string userName,
    > bool createPersistentCookie,
    > string strCookiePath
    > );
    >
    > I've attached my control files
    >
    >
    > "Janaka" <> wrote in message
    > news:...
    >> Grant,
    >>
    >> Is this a local app you are debugging or on the live server? Try setting
    >> the domain property of the cookie. That may clear up the double cookie
    >> problem.
    >>
    >> Janaka
    >>
    >> "Grant Merwitz" <> wrote in message
    >> news:%...
    >>> Hi, i am using forms authentication in an ASP.NET project
    >>>
    >>> I am setting the Forms authentication cookie by using:
    >>> FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);
    >>>
    >>> Now when i review my trace on my page, there are two cookies created
    >>> that
    >>> look identical.
    >>> When i FormsAuthentication.SignOut() they both dissappear.
    >>>
    >>> Any ideas as to why two cookies are created?
    >>>
    >>> TIA
    >>>
    >>>
    >>>

    >>
    >>

    >
    >
    >
    Janaka, Mar 2, 2005
    #3
    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. fadi
    Replies:
    1
    Views:
    504
  2. TaeHo Yoo
    Replies:
    1
    Views:
    520
    Teemu Keiski
    Jul 9, 2003
  3. Jeff Johnson
    Replies:
    6
    Views:
    3,754
    tharadk
    Jul 24, 2009
  4. Tommy
    Replies:
    1
    Views:
    2,066
    S. Justin Gengo
    Aug 7, 2003
  5. Lauchlan M
    Replies:
    2
    Views:
    494
    John Saunders
    Aug 17, 2003
Loading...

Share This Page