Authentication Cookie & cookie sub keys

Results 1 to 2 of 2

Thread: Authentication Cookie & cookie sub keys

  1. #1
    Join Date
    Dec 1969

    Default Authentication Cookie & cookie sub keys

    I have posted this in other forums outside of and am still looking for an answer.<BR><BR><BR>Is there any way of adding sub keys to an authentication cookie? <BR><BR>For example: <BR>&#060;% Response.Write(User.Identity.Name(0)) %&#062; <BR>&#060;% Response.Write(User.Identity.Name(1)) %&#062; <BR>&#060;% Response.Write(User.Identity.Name(2)) %&#062; <BR><BR>Here is what my sign in currently looks like: <BR><BR>&#060;% <BR>Dim C As System.Web.HttpCookie = _ <BR>System.Web.Security.FormsAuthentication.GetAut hCookie((var0 & "_" & var1 & "_" & var2), False) <BR>C.Domain = "" <BR>Response.AppendCookie(C) <BR>%&#062; <BR><BR>I then split at the underscore, but I want to use cookie sub keys..

  2. #2
    Join Date
    Dec 1969

    Default I'm not sure if this is what you want

    but if you&#039;re trying to store information about the user, ie First/Last name, email address etc, perhaps for use elsewhere in the site, I create what i&#039;ve called a "Customer" class with public fields which I then assign the data to for reference later, you can also store the customer object in a cookie for reference later.<BR><BR>You can store all you need to in this, including roles etc. I&#039;ve just quickly written this so there may be errors but I have the working code if you need it.<BR><BR>Hope this helps.<BR><BR>Tim<BR><BR>[code language="VB.NET"]<BR>Public Class Customer<BR> Public CustID As Integer<BR> Public FName As String<BR> Public LName As String<BR> Public Email As String<BR>End Class<BR><BR>Public Class CustomerDetails<BR> Public Function GetCustomerDetails(ByVal customerID As Integer) As Customer<BR><BR> Dim cust As New Customer<BR> cust.CustID = 1<BR> cust.FName = "Tim"<BR> cust.LName = "Gaunt"<BR> cust.Email = ""<BR>Return (cust)<BR><BR> End Function<BR>End Class<BR><BR>Private Sub btnLogonClick(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles btnLogon.Click<BR><BR>&#039;User has been authorised so assign info<BR>Dim cust As CustomerDetails = New CustomerDetails<BR>Dim details As Customer = cust.GetCustomerDetails(custID)<BR>Response.Cookie s("CPrinFullName").Value = details.FullName<BR>Session("CustomerSession") = details<BR><BR>End Sub<BR>[/code]

Posting Permissions

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