Forms Authentication UserData

Discussion in 'ASP .Net' started by Brian Shannon, Aug 16, 2004.

  1. Using forms authentication I want to add several pieces of data to the
    UserData property in the Forms Ticket.

    I want to include roles, email, user ID.

    From reading it seems like you add all that to a string and add it to the
    UserData property.

    If that is the case how do you access each individual piece such as email.
    I am not completely up to date with using ASP.NET's cookies so bare with me.

    Thanks
     
    Brian Shannon, Aug 16, 2004
    #1
    1. Advertising

  2. Brian Shannon

    Karl Guest

    Brian,
    What I've done in the past is simply store the ID and look up the user from
    that (users should be cached, so no perf issue)

    int userId = Convert.ToInt32(context.User.Identity.Name);
    MyUserClass user = MyUserClass.GetUser(userId);
    string email = user.Email;


    the GetUser function looks something like:
    public static User GetUser(int userId){
    User user = (User)HttpRuntime.Cache[userId.ToString()]
    if (user == null){
    //get from DB and store in cache for next time.
    }
    return user;
    }

    Karl

    "Brian Shannon" <> wrote in message
    news:...
    > Using forms authentication I want to add several pieces of data to the
    > UserData property in the Forms Ticket.
    >
    > I want to include roles, email, user ID.
    >
    > From reading it seems like you add all that to a string and add it to the
    > UserData property.
    >
    > If that is the case how do you access each individual piece such as email.
    > I am not completely up to date with using ASP.NET's cookies so bare with

    me.
    >
    > Thanks
    >
    >
     
    Karl, Aug 16, 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. e
    Replies:
    1
    Views:
    3,635
    John Saunders
    Oct 24, 2003
  2. Sean Patterson

    Authentication Ticket not storing UserData

    Sean Patterson, Jan 25, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    642
    Sean Patterson
    Jan 25, 2005
  3. Peter Rilling
    Replies:
    1
    Views:
    864
    bruce barker \(sqlwork.com\)
    Aug 3, 2006
  4. =?Utf-8?B?SGFyZHkgV2FuZw==?=

    Forms Authentication with UserData Problem

    =?Utf-8?B?SGFyZHkgV2FuZw==?=, Feb 15, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    2,900
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
    Feb 16, 2007
  5. John Kievlan

    Cannot retrieve UserData in Forms Authentication

    John Kievlan, Jul 24, 2003, in forum: ASP .Net Security
    Replies:
    1
    Views:
    383
    tom hamilton
    Jul 25, 2003
Loading...

Share This Page