User.Identity.Name

G

Guest

I have a ASP.NET (using vb.net) application setup that allows someone to
fill out an application form. The form goes across multiple pages (10) so on
the first page I assign a unique ID and store it in a cookie and use it
across the reamining pages. I am storing each pages data to the SQL database
after they click the NEXT button to advance to the next page. Then, if they
click the back button to the other pages to change the information I can
populate the pages by getting the userId stored in the cookie. I use the
GetUserID function listed below on each page to retrieve their ID number.
After they have filled everything out they are assigned a username and
password to login later to make any changes to their information. I am using
the same GetUserID function to get the userid for each page. Everything has
been working great without any problems. However, the other day something
strange was happening. Someone would fill out all the pages(10)of information
and later if I would go to the first page that persons information would be
populated. I was not using the same machine they were and it would happen to
anyone going to that page. It was like the user.identity.name was stored in a
global session or something.

I ended up having to delete that particular user out of the database in
order for it to stop populating that users information.

Any ideas why this happened? Is my GetUserID logic incorrect?


Public Function GetUserId() As String

Dim context As HttpContext = HttpContext.Current

' If the user is authenticated, use their customerId

If context.User.Identity.Name <> "" Then
Return context.User.Identity.Name
End If

' If user is not authenticated, either fetch it or return empty string
If Not context.Request.Cookies("User_ID") Is Nothing Then
Return context.Request.Cookies("User_ID").Value

Else
Return String.Empty

End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top