Re: New to Classes, please help.



Hmm.. OK.

I'm following you for the most part in your sample, but once it is in the
Session var, how do I reference it again somewhere else?

Thanks,

David Lozzi


"Peter MacMillan" <peter@xxxxxxxxxxxxx> wrote in message
news:A5WdnXGT8L2k3dffRVn-sA@xxxxxxxxxxxxx
> David Lozzi wrote:
>> Howdy,
>>
>> I'm new to classes. Below is my class User. (is this a reserved namespace
>> or class?) It works great, kind of. If I specify the username and
>> password, the correct firstname and lastname are returned. For example,
>> username dlozzi, password fun. It returns David Lozzi as full name. If I
>> login as someone else on another computer, say username dsmith and
>> password fun2, the second computer displays the correct fullname. HOWEVER
>> if I refresh the page on the first computer where I logged in under
>> dlozzi, the information is now dsmith's info. I believe I am just missing
>> one small piece, but I just cannot find it. Should I be using Session
>> states along with classes?
>>
>> Thanks!
>>
>
>
> Your problem is coming from all of your methods and properties being
> shared. I'm not sure how to explain this without going all-out on OO
> methodology... "shared" means there is only one of that thing for the
> class.
>
> You're right to have the login method (method is an OO word for
> procedure/function).
>
> You want something like:
>
> Public Class User
> Private m_username As String
>
> Public Sub New()
> End Sub
>
> Public Property Username() As String
> Get
> Return m_username
> End Get
> Set(ByVal value As String)
> m_username = value
> End Set
> End Property
>
> Public Shared Function Login(ByVal username As String) As User
>
> Dim result As User
> result = new User()
> result.Username = username
> return result
>
> End Function
> End Class
>
>
> (I don't guarantee that the above will work because I just typed it out in
> my newsreader. It should show you what needs to be done).
>
> Now from whereever you're loging them in, you call the Login function to
> get a User object. You can then store that User into the Session (say, put
> it in Session("UserObject") or something like that.
>
> --
> Peter MacMillan
> e-mail/msn: peter@xxxxxxxxxxxxx icq: 1-874-927
>
> GCS/IT/L d-(-)>-pu s():(-) a- C+++(++++)>$ UL>$ P++ L+ E-(-) W++(+++)>$ N
> o w++>$ O !M- V PS PE Y+ t++ 5 X R* tv- b++(+) DI D+(++)>$ G e++ h r--
> y(--)


.



Relevant Pages

  • Re: Using Windows Login
    ... given how easy it is to reset an environment variable. ... USERNAME variable to whatever you want, then open Access using a command ... Dim rst As Recordset, strString As String, tempstring As String ... Subject: Using Windows Login ...
    (microsoft.public.access.security)
  • Re: New to Classes, please help.
    ... user object is saved in the user's session state. ... Private _firstname As String ... Public Property UserName() As String ...
    (microsoft.public.dotnet.framework.aspnet)
  • session value lost
    ... into as sessionvariable (username). ... I save the recordid to the session and redirect to work.aspx. ... and I will change the username from manuel login to ...
    (microsoft.public.dotnet.framework.aspnet)
  • loosing session value - sometimes
    ... into as sessionvariable (username). ... I save the recordid to the session and redirect to work.aspx. ... and I will change the username from manuel login to ...
    (microsoft.public.dotnet.security)
  • Re: Client/server application and Windows Integrated Auth
    ... > have to enter a login name and password. ... the username *and* the corresponding password. ... > Is my assessment of how to implement Windows Integrated auth correct? ... > private static string GetSid ...
    (microsoft.public.dotnet.framework.windowsforms)