468,544 Members | 1,767 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,544 developers. It's quick & easy.

Session in ASP

145 100+
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.
Oct 10 '09 #1
3 1548
564 Expert 512MB
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
  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. %>
Remember this is a start for you. So don't give up easily.

We are here to help,
Oct 10 '09 #2
145 100+
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");
  4.             sql2 ="SELECT * from Login WHERE " + "Username='" +  Uname + "' AND " + "UserPassword='"+ Upswrd + "'";
  5.             rs.Open(sql2,Conn);
  7.             if(!(rs.EOF))
  8.             {
  9.                 Session("loginstatus")="OK";
  10.                 Session("sesiUsername")=String(Uname);
  11.                 Session("sesiUserType")=String(rs.fields.item("UserType"));
  13.                 if((Session("sesiUserType"))=="admin")
  14.                     Response.Redirect("menuAdm.asp?xx="+a+"");
  16.                 if((Session("sesiUserType"))=="employee")
  17.                     Response.Redirect("menuEmp.asp?xx="+a+"");
  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")
Oct 17 '09 #3
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
  3. ' * print your edit button
  5. End If
That controls the display of the edit button.
Oct 20 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Damien | last post: by
1 post views Thread by mudge | last post: by
5 posts views Thread by Abhilash.k.m | last post: by
reply views Thread by joseph conrad | last post: by
14 posts views Thread by aroraamit81 | last post: by
7 posts views Thread by aroraamit81 | last post: by
reply views Thread by TRB_NV | last post: by
1 post views Thread by Santosh | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.