Seeion name and validation

Hello all,

I'have a login page that looks up a database table and if the username and password is correct, it lets users further to the other web pages.  In each web page's header, I have the below, so that if the user attempts to open a page without logging in, the user is forwared to the login page.
<%
If Session("name") = false Then
    Response.Redirect("loginpage.asp")
End If
%>

I also have other few pages that only the supervisor can enter.

<%
If Session("name") <> "userx" Then
    Response.Redirect("loginpage.asp")
End If
%>

That was working fine for me. But now, I need three users; userx, usery and userz to be able to view these few pages.  How can I modify the above code so that all three users can view the page?

I tried the below knowing that it is daft to do so, and of course it didnt work.  What is the correct syntax please?
<%
If Session("name") <> "userx,usery,userz" Then
    Response.Redirect("loginpage.asp")
End If
%>

Thanks

bedeviAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TimCotteeHead of Software ServicesCommented:
Hi bedevi,

If Session("Name") <> "userx" And Session("Name") <> "usery" And Session("Name ") <> "userz" Then

Though this will get difficult to maintain in the long run, this is where it is worthwhile linking this to a database and using that to maintain your users.

Tim Cottee
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GENTPCommented:
As above stated, using a database of users would be the 'best' way to go on this.

Sticking with the way you're going about things, I'd create a function to validate everything. Do a seperate if statement for each user (this way you could quick add/remove a line (but you need to redeploy each time still) and simply return a boolean value.

Then all you need to do is:
if validateUser(Session("name")) then
        response.redirect("loginpage.asp")
else
        'load page and do everything you want to
end if
0
bedeviAuthor Commented:
I did this on a first come first server basis I hope it is fair.
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.