Forms authentication - how to retrieve logged-in username?

Discussion in 'ASP .Net' started by Paul W, Nov 3, 2004.

  1. Paul W

    Paul W Guest

    I've got Forms Authentication up and running. The starting page for the app.
    is default.aspx. I want to display on the top of this form a 'You are logged
    in as Fredxyz' message.

    If the user is a return user and was automatically logged in by a persistent
    auth. cookie, how can I find out the 'username' that he's logged in as?

    Thanks,

    Paul.
    Paul W, Nov 3, 2004
    #1
    1. Advertising

  2. The HttpContext.Current.User.Identity.Name will return the value that has
    been set for the name field. Howevery, this is often just an ID number or
    something else. You can create your own identity class based on the
    IIdentity interface. You can also generate a custom ticket to pass with the
    forms authentication. This has the benefit of having custom data stored in a
    custom data field for the ticket that could be used to store the user's
    name.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage

    "Paul W" <> wrote in message
    news:...
    > I've got Forms Authentication up and running. The starting page for the
    > app. is default.aspx. I want to display on the top of this form a 'You are
    > logged in as Fredxyz' message.
    >
    > If the user is a return user and was automatically logged in by a
    > persistent auth. cookie, how can I find out the 'username' that he's
    > logged in as?
    >
    > Thanks,
    >
    > Paul.
    >
    Mark Fitzpatrick, Nov 3, 2004
    #2
    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. Mike
    Replies:
    0
    Views:
    382
  2. keithb
    Replies:
    0
    Views:
    618
    keithb
    Feb 16, 2006
  3. Replies:
    1
    Views:
    929
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2007
  4. ThaYoung1!
    Replies:
    0
    Views:
    156
    ThaYoung1!
    Aug 7, 2003
  5. Lauchlan M

    When exactly are you logged in? (Forms authentication)

    Lauchlan M, Oct 2, 2003, in forum: ASP .Net Security
    Replies:
    2
    Views:
    125
    Lauchlan M
    Oct 2, 2003
Loading...

Share This Page