Use user ID in other page
I want to create log in page with c# asp.net. I do it. Now when the user is log in, I want to get user ID and use it in other pa开发者_如何学编程ge. How can i do it? Thank you for your help
When users log in, you should store it probably into a session variable. When the user navigates the other pages you can access it via that session variable.
You can use an encrypted cookie to store the user details and their roles. That way you can also implement the 'log me in automatically' function that a lot of websites use.
Of course all you are doing is reinventing Forms Authentication, but it is a good learning experience.
With Forms Authentication, you have login, password reset, user creation controls created for you, and you can plug in your own MembershipProvider and RoleProvider to access an existing data store.
You should use Forms Authentication for ASP.Net
This is a very good tutorial about it: https://web.archive.org/web/20211020150650/http://www.4guysfromrolla.com/webtech/110701-1.shtml
精彩评论