Best practice for user/customer repository

S

Shlomi

Hi,

Until now I used the Session("x")="y" method for saving user or
customer info throw web pages (differently for each session) like that:

Session("UserName")="Bob"

My questions:
==========

In Asp.net 1, is there another way, cleaner and structured for doing
the same thing? Something like a class and syntax like
obj_User.UserName="Bob" (Important: without the necessity to declare
obj_User in each page!).

Are they any articles on that issue in the web?

Thank You,

Shlomi
 
O

OHM \( One Handed Man \)

Ok, create the following class , this can be called from within another
class beit, page or one of your own. You should set this on session start to
the users name. So the users name call bed called CurrentUser.Name

Public Class CurrentUser

Public Shared Property Name()
Get
Return HttpContext.Current.Session("UserName")
End Get
Set(ByVal value)
HttpContext.Current.Session("UserName") = value
End Set
End Property

End Class
 
S

Shlomi

Yes, but how to avoid declaring an instance of a class in each page
that I approach?
Do I have to use session variable anyhow?
 
G

Guest

Hi,

Have you thought of using forms authentication?

Then you have available ..

HttpContext.Current.User

Wozza
 
S

sloan

Check my blog
http://spaces.msn.com/sholliday/ 10/24/2005 entry

I have a cleaner way to store objects in the SESSION variable.

I'd create an object

class UserInfo
{
public string UserName
{ get { return this.m_myname; }}

}

and use my wrapper object to store instantiations of this object.

...
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top