NetTalk Web Server > Web Server - Share Knowledge

Example code for logging in a user

(1/1)

John Hickey:
From the newsgroup, Steve Ellis asked:

Does anyone have an example of how to do a logon that verifies a userid and password against a server database?

Nick L answered:

Yes,
Include the tables you need to validate against but use the web form to
memory and local Li/Pw variables.
I validate 2 tables, the "users"(AFF) and "user group(UGRP)".

In the embed "Validate Update" I do a lookup to the "Users" using the key
login and then the user group to compare with the local vars to pass the
login and password. I then lookup the group to get the group access level
then set some session variables as in the example below. Any suggestions to
streamline this would be appreciated, anyone??

!Get login credentials
 If Loc:Login<>''
    If upper(Loc:Login) = upper(AFF:Login) and upper(Loc:Password) =
upper(AFF:Password)
            p_web.SetSessionValue('AffiliateID',clip(AFF:AffiliateID))
            p_web.SetSessionValue('AFFLevel1',clip(UGRP:AccessLevel))
            p_web.ValidateLogin()
            !p_web.SetSessionLoggedIn(1)
    Else
            p_web.SetSessionValue('LoginMessage','Try again')
    End !If
 Else
            p_web.SetSessionValue('LoginMessage','Login required, try
again')
End !If

****end example*****

Edvard Korsbaek:
I see that if everything is OK, you set:
p_web.validatelogin()
The word is 'Validate', but does it mean that you are logged in?
What I really need is some doc on the different p_web methods, but do they exist?

Edvard Korsbæk

Bruce:
Hi Edvard,

The problem with documentation is that it is imprecise. What we need is a more structured language to explain what is going on. Hah - I know we'll write the documentation in Clarion - that way there's no ambiguity. So you can see a full document of exactly what the methods do in the netweb.inc and netweb.clw files. (I'm just pulling your leg Edvard, sorry... :D )

Seriously though - The ValidateLogin() method is the same as .SetSessionLoggedIn(true). So if you call it, then the user becomes "logged in".

there'll be more information about each method once the method list has stabilized a bit.

Cheers
Bruce


Navigation

[0] Message Index

Go to full version