开发者

Sharing User Specific Variables in VB.net

开发者 https://www.devze.com 2023-03-11 05:21 出处:网络
I am building an ASPX web site which has several pages and multiple users. I grab specific info about each user such as UserName, ID, etc. when they start a session and I need to retain this info and

I am building an ASPX web site which has several pages and multiple users. I grab specific info about each user such as UserName, ID, etc. when they start a session and I need to retain this info and have access to it from each page (which has it's own class). Can someone give me a general idea of best practices regarding this? I'm a beginner/novice at VB and still struggling with class concepts. I know i can create a global file and share variables publicly, but i need开发者_JAVA百科 the variable values to be specific to the user, not the entire application. Any pointers or advice is appreciated.


Your pages/controls will have access to SessionState - if you are a novice this is the easiest solution.


I suggest you read up on Sessions. These are stored server side and contain information on each individual. By default, they are stored in memory, so if you're going to have lots, you can store them in a SQL Server.

Cookies are another way of identifying people. They are stored on the client's computer and sent with any requests they make. Being on the client's computer, they are more easily tampered with than sessions, but if you don't have sensitive information, it may be a better approach since your server won't have to store the information. Cookies can also be encrypted for better security. Sessions, internally, use cookies (unless you turn CookieLess mode on) in order to track the user. However, cookies sent by sessions only contain ID to track the user, not the actual information itself (such as username).

0

精彩评论

暂无评论...
验证码 换一张
取 消