sessions and forms authentication tickets

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default sessions and forms authentication tickets

    When implementing ASP.NET forms authentication everything worked out just
    fine. I wanted to add the UserID and UserFName to my usage so I would have
    this information throughout their session without having to return to the
    database. I am upgrading from ASP so my first thought is Session(?UserID?)
    which works fine if the user stays in the same folder (members). But if
    they click a link outside that folder and return to that folder the Session
    values I had set are now gone.

    I use the return path code so when they click the login link it takes them
    to the default.aspx login page without logging in again. Like I said
    earlier, when they login the Session values work, and if they click links
    in the same folder (members) the Session values work, but if they go to
    another folder and return to the members folder the Session values are gone.

    Should I not use Session(?Value?)? How can I add other values to the
    FormsAuth Ticket we created and use in my pages to display User Name?

    --
    Message posted via [url]http://www.dotnetmonster.com[/url]
    Justin Morris via DotNetMonster.com Guest

  2. Similar Questions and Discussions

    1. Accessing htm files without authentication (forms authentication)
      I have application with forms authentication. All works fine. When user opens .aspx file gets login form, login and then get the .aspx page. But...
    2. ASP.Net Forms authentication with basic authentication popup
      Relatively new to ASP.Net but have a strange problem. My site uses forms authentication for a large administration section however after the user...
    3. Forms authentication then redirection to a secure web with NT authentication?
      Hi, I want to allow access to particular secured intranet web sites. These intranet are stored in sharepoint (2003 version) Actually I've...
    4. Authentication ticket, cookieless, forms authentication?
      Hi. I want to use Forms Authentication, cookieless. The issue is setting the Authentication Ticket without using cookies (!) That is, the...
    5. Sessions, authentication and $_SERVER
      I'm trying to understand sessions and authentication. I gathered that the only way of preserving data across script invocations was to use a...
  3. #2

    Default Re: sessions and forms authentication tickets

    You can easily add custom data to an auth cookie by using the following:

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
    1,
    email,
    System.DateTime.Now,
    System.DateTime.Now.AddMinutes(30),
    false, // not persistent
    userData, // <-- THIS CAN BE A STRING OF YOUR CUSTOM DATA, PERHAPS
    SEMI-COLON DELIMITED.
    FormsAuthentication.FormsCookiePath);

    Note: the 'userdata' variable which is of type string.

    --

    - Paul Glavich
    ASP.NET MVP
    ASPInsider ([url]www.aspinsiders.com[/url])


    "Justin Morris via DotNetMonster.com" <forum@nospam.DotNetMonster.com> wrote
    in message news:a6cbd5f34654423a9537afe03f335fa1@DotNetMonste r.com...
    > When implementing ASP.NET forms authentication everything worked out just
    > fine. I wanted to add the UserID and UserFName to my usage so I would
    have
    > this information throughout their session without having to return to the
    > database. I am upgrading from ASP so my first thought is
    Session(?UserID?)
    > which works fine if the user stays in the same folder (members). But if
    > they click a link outside that folder and return to that folder the
    Session
    > values I had set are now gone.
    >
    > I use the return path code so when they click the login link it takes them
    > to the default.aspx login page without logging in again. Like I said
    > earlier, when they login the Session values work, and if they click links
    > in the same folder (members) the Session values work, but if they go to
    > another folder and return to the members folder the Session values are
    gone.
    >
    > Should I not use Session(?Value?)? How can I add other values to the
    > FormsAuth Ticket we created and use in my pages to display User Name?
    >
    > --
    > Message posted via [url]http://www.dotnetmonster.com[/url]

    Paul Glavich [MVP ASP.NET] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139