Seeion name and validation

Posted on 2006-04-24
Last Modified: 2010-04-06
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
End If

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

If Session("name") <> "userx" Then
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
End If


Question by:bedevi
    LVL 44

    Accepted Solution

    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
    LVL 5

    Assisted Solution

    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
            'load page and do everything you want to
    end if

    Author Comment

    I did this on a first come first server basis I hope it is fair.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
    Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to count occurrences of each item in an array.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now