FormsAuthentication cookie

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • G-Fit

    #1

    FormsAuthentication cookie

    Hello group,

    I use Forms Authentication in my web application and I am not sure I
    understand the way the cookie works.

    I use the SetAuthCookie method with a database identifier as userName, as
    I would like the website to remember who is logged in (and I guess it
    doesn't matter wether I store a name or an identifier, which is much more
    convenient for me) :

    FormsAuthentica tion.SetAuthCoo kie(reader["CTC_ID"].ToString(), true);

    But then, I don't find any way to get it back later. The cookie contains
    a very long string, is it encrypted ? Or do I need to set up a special
    cookie to store my identifier ?

    Karine Proot
    G-Fit


  • Andy Fish

    #2
    Re: FormsAuthentica tion cookie

    AFAIK you cann't access the forms authentication cookie in the same way as
    you would a normal cookie - it is used intermally by the forms
    authentication processing. The only reason for specifying a particular
    cookie is to avoid a possible name mismatch with other cookies, or other web
    apps running on the same server.

    If you want to store information about the user I think you should use the
    Session object as normal. However, be aware that the forms authentication
    timeout might not be the same as the session timeout, so your code cannot
    assume that a Session exists if and only if the user is authenticated.

    Andy

    "G-Fit" <msdn@g-fit.fr> wrote in message
    news:%233km6NnM EHA.3052@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > Hello group,
    >
    > I use Forms Authentication in my web application and I am not sure I
    > understand the way the cookie works.
    >
    > I use the SetAuthCookie method with a database identifier as userName,[/color]
    as[color=blue]
    > I would like the website to remember who is logged in (and I guess it
    > doesn't matter wether I store a name or an identifier, which is much more
    > convenient for me) :
    >
    > FormsAuthentica tion.SetAuthCoo kie(reader["CTC_ID"].ToString(), true);
    >
    > But then, I don't find any way to get it back later. The cookie[/color]
    contains[color=blue]
    > a very long string, is it encrypted ? Or do I need to set up a special
    > cookie to store my identifier ?
    >
    > Karine Proot
    > G-Fit
    >
    >[/color]


    Comment

    • G-Fit

      #3
      Re: FormsAuthentica tion cookie


      "Andy Fish" <ajfish@blueyon der.co.uk> a écrit dans le message de
      news:Bn5mc.2341 $wt5.22262917@n ews-text.cableinet. net...[color=blue]
      > AFAIK you cann't access the forms authentication cookie in the same way as
      > you would a normal cookie - it is used intermally by the forms
      > authentication processing. The only reason for specifying a particular
      > cookie is to avoid a possible name mismatch with other cookies, or other[/color]
      web[color=blue]
      > apps running on the same server.
      >
      > If you want to store information about the user I think you should use the
      > Session object as normal. However, be aware that the forms authentication
      > timeout might not be the same as the session timeout, so your code cannot
      > assume that a Session exists if and only if the user is authenticated.[/color]

      That is exactly the problem I have, and that's why I tried to use the
      authentication cookie alone.
      Anyway, thanks for your answer !


      Comment

      Working...