2 separate cookies in asp

C

collie

i need to create 2 separate cookies in asp to be read later on in
asp.net. I need to create an ADMIN cookie and a User cookie. In my
database i have a table called users. if the field ACCESS=admin then i
need to create an admin cookie if ACCESS =user then i need to create a
user cookie. The page is redirected to an aspx page where it reads the
cookie. if the cookie is admin then access to the entire site should
be possible otherwise access should be limited to a few pages.
I created a user cookie (below) which works fine both in asp and
vb.net. my problem is that now i need to create another cookie for the
admin. if access=admin then create a new cookie. How do i do that?

Thanks.

<!--#include file="/connDUclassified.asp" -->
<%
Dim rsUser__MMColParam
rsUser__MMColParam = "0"
if (Session("MM_Username") <> "") then rsUser__MMColParam =
Session("MM_Username") end if

%>
<%
set rsUser = Server.CreateObject("ADODB.Recordset")
rsUser.ActiveConnection = MM_connDUclassified_STRING
rsUser.Source = "SELECT U_ID, U_FIRST, U_LAST FROM USERS WHERE U_ID
= '" + Replace(rsUser__MMColParam, "'", "''") + "'"
rsUser.CursorType = 0
rsUser.CursorLocation = 2
rsUser.LockType = 3
rsUser.Open()
rsUser_numRows = 0
%>
<%
Dim rsAds__MMColParam
rsAds__MMColParam = "0"
if (Session("MM_Username") <> "") then rsAds__MMColParam =
Session("MM_Username")
%>

<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?"
+ Request.QueryString
MM_valUsername=CStr(Request.Form("Username"))

If MM_valUsername <> "" Then

MM_fldUserAuthorization=""
MM_redirectLoginSuccess="myAds.asp"

MM_redirectLoginFailed="myAds.asp"

MM_flag="ADODB.Recordset"
set MM_rsUser = Server.CreateObject(MM_flag)
MM_rsUser.ActiveConnection = MM_connDUclassified_STRING
MM_rsUser.Source = "SELECT U_ID, U_PASSWORD"
If MM_fldUserAuthorization <> "" Then MM_rsUser.Source =
MM_rsUser.Source & "," & MM_fldUserAuthorization
MM_rsUser.Source = MM_rsUser.Source & " FROM USERS WHERE U_ID='" &
MM_valUsername &"' AND U_PASSWORD='" & CStr(Request.Form("Password"))
& "'"
MM_rsUser.CursorType = 0
MM_rsUser.CursorLocation = 2
MM_rsUser.LockType = 3
MM_rsUser.Open


If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
' username and password match - this is a valid user
'--create user cookie

Response.Cookies("Name")("Username") = Request.Form("UserName")
Response.Cookies ("Name")("Password")=Request.Form ("Password")
Response.Cookies("Name").Path = "/"
Response.Cookies ("Name").expires =dateadd("h",1,now())


Response.Write(Request.Cookies("Name")("Username"))
Response.Write (Request.Cookies("Name")("Password"))
'---end user cookie


Session("MM_Username") = MM_valUsername
If (MM_fldUserAuthorization <> "") Then

Session("MM_UserAuthorization") =
CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
Else
Session("MM_UserAuthorization") = ""

End If
if CStr(Request.QueryString("accessdenied")) <> "" And false Then
MM_redirectLoginSuccess = Request.QueryString("accessdenied")

End If
MM_rsUser.Close
Response.Redirect(MM_redirectLoginSuccess)


End If

MM_rsUser.Close
Response.Redirect(MM_redirectLoginFailed)

End If
%>
<%
</SCRIPT>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1255">

<form name="LOGIN" method="post" action="<%=MM_LoginAction%>">

<td align="center" valign="middle">
<TABLE cellpadding=2 cellspacing=0 border=0>
<TR>
<TD align=right dir=rtl><font face="Verdana, Arial, Helvetica,
sans-serif" size="3">USERNAME</font></TD><TD><input type="text"
name="Username" id="Username" size="15"></TD>
</TR>
<TR>
<TD align=right dir=rtl><font face="Verdana, Arial, Helvetica,
sans-serif" size="3">PASSWORD</font></TD><TD><input type="password"
name="Password" size="15"></TD>
</TR>
<TR>
<TD colspan=2 align=center> <input type="submit" name="Submit2"
value="LOGIN"></TD>
</TR>
</TABLE>
</body>
</html>

<%
rsUser.Close()
%>
<%
rsAds.Close()
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top