Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directing users to web page according to their level

Status
Not open for further replies.

necta

Technical User
Mar 8, 2004
35
MY
My web site has 3 level of users. I) Admin which can access all the web pages. 2) staff which can access to the certain part of the user and 3) customer which can only access another part of web pages.
Upon login, users are directed to those web pages according to their level. I understand that session can do the job but I am new to ‘session’, I wonder how would I place the session object.
Can anybody give me a hand? Thank you.
 
Do you want to control access to sets of pages or to content within each page?

To control access to sets of pages you might place them in separate folders withing the website. For example,
would be the folder for the staff pages. This approach can work if you have entirely different pages for each group. It might mean that you would be putting copies of some pages in different folders whenever the page was available to more than one group.

To control access to content within a page do something like this.
Code:
Dim userGroup, salary
userGroup = Session("user_group")
...
If userGroup = "Admin" Then

Response.Write "The boss' salary is " & salary

Endif

If userGroup = "Staff" Then

Response.Write "You are not allowed to see this information."

Endif


The session variable is defined in the page that processes the login.

Code:
Dim user_level
...
' Determine whether the login is valid.
' Determine which group the user belongs to.
...
If user_level = "TopDog" Then

  Session("user_group") = "Admin"

ElseIf user_level = "Peon" Then

  Session("user_group") = "Staff"

Else 

  Session("user_group") = "Customer"

Endif
 
Hi,
Thanks, I will try on it.
Actually, I will have three different sets of menu for each type of users. The admin will hv the menu with all links to the other web pages while customer will have the least menu links.

rgrds,
Necta
 
Yes, control the navigation that way.

Take it one step further and put the navigation in a separate file which looks at the Session variable and builds the navigation menu. This way you have one line in every page for the navigation plus you only have one file to modify when the navigation changes due to new pages and dropped pages.
Code:
<% 'ASP stuff %>
<html>
<head></head>
<body>

Fixed content and HTML.

<% 'More ASP stuff %>

<!-- #include virtual="/design/nav.asp" -->

More fixed content and HTML.


</body>
</html>

For stronger control add code at the beginning of each page to check the user level and redirect them if they are not allowed to view the page. Again that can be one file that you include on each page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top