Connecting Tech Pros Worldwide Forums | Help | Site Map

Session in ASP

Member
 
Join Date: Jul 2008
Posts: 123
#1: Oct 10 '09
Can anyone help me on session? I want to create a session for certain username and password which the person only can view certain pages on the website only...For example if the user are registered they can view the products webpage, make order and change their profile. A non registered customer cannot make an order but need to registered first. An admin can view all webpages include change the products. An employee can change the customer profile, make order for the customer.

Lastly, how to get the customer name from the login and the name are automatically there on the order webpage.

CroCrew's Avatar
Expert
 
Join Date: Jan 2008
Location: Michigan
Posts: 338
#2: Oct 10 '09

re: Session in ASP


Hello puT3,

Here is a start for you. If you need more help after you start on this then post the code that you are having problems with.

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     Session("UserLoggedIn") = false
  3.  
  4.     If (Session("UserLoggedIn")) Then
  5.         Response.Write("<u>Show This</u><br />")
  6.         Response.Write("View the products webpage<br />")
  7.         Response.Write("Make order<br />")
  8.         Response.Write("Change their profile<br />")
  9.     Else
  10.         Response.Write("Registered first")
  11.     End If
  12. %>
  13.  
Remember this is a start for you. So don't give up easily.

We are here to help,
CroCrew~
Member
 
Join Date: Jul 2008
Posts: 123
#3: Oct 17 '09

re: Session in ASP


i already succeed in creating session and to differentiate it between user...now im trying to make a user for example a customer to change their own personal information...

after they login, they can change the information by clicking on edit profile link...so how can i get their information which is stored in access database by using the session?

the code im using for the session is
Expand|Select|Wrap|Line Numbers
  1. var Uname = Request.Form("nama");
  2.             var Upswrd = Request.Form("pass");
  3.  
  4.             sql2 ="SELECT * from Login WHERE " + "Username='" +  Uname + "' AND " + "UserPassword='"+ Upswrd + "'";
  5.             rs.Open(sql2,Conn);
  6.  
  7.             if(!(rs.EOF))
  8.             {
  9.                 Session("loginstatus")="OK";
  10.                 Session("sesiUsername")=String(Uname);
  11.                 Session("sesiUserType")=String(rs.fields.item("UserType"));
  12.  
  13.                 if((Session("sesiUserType"))=="admin")
  14.                     Response.Redirect("menuAdm.asp?xx="+a+"");
  15.  
  16.                 if((Session("sesiUserType"))=="employee")
  17.                     Response.Redirect("menuEmp.asp?xx="+a+"");
  18.  
  19.                 if((Session("sesiUserType"))=="customer")
  20.                     Response.Redirect("menuCust.asp?xx="+a+"");
and for every other page i use this
Expand|Select|Wrap|Line Numbers
  1. Session("sesiUsername")
  2.  
Newbie
 
Join Date: Oct 2009
Location: Grant, AL
Posts: 17
#4: Oct 20 '09

re: Session in ASP


On the page where you want to display the edit button only for the user whose page it is and for all admin, here is a structure you can use:

Expand|Select|Wrap|Line Numbers
  1. If Session("sesiUserName") = Request.Form("UserName") or Session("sesiUserType") = "admin" Then
  2.  
  3. ' * print your edit button
  4.  
  5. End If
  6.  
That controls the display of the edit button.
Reply