Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Problems with Cookies


Message #1 by "Eric Mulartrick" <emulartr@v...> on Tue, 25 Mar 2003 06:07:52
I'm trying to figure out why my cookies are not working for the .asp page 
I'm working on.  It's an administrative login page and if they select that 
they want to use cookies to remember their password, it should do so.  
Here is a little bit of my code that I'm using:

<%
  strDSN = "FILEDSN=C:\Inetpub\wwwroot\member.dsn"

  	Set cn = Server.CreateObject("ADODB.Connection")
  	cn.Open strDSN

  	Set cmdCommand = Server.CreateObject("ADODB.Command")
  	cmdCommand.ActiveConnection = cn

  	Set rs1 = Server.CreateObject("ADODB.Recordset")

  	cmdCommand.CommandText = "SELECT * FROM Members WHERE " & _
	                 "PID='" & Request.Form("login") & "' AND " & _
                	 "PW='" & Request.Form("pword") & "' "

  	rs1.Open cmdCommand, , 3

  	Set objPID = rs1("PID")
	Set objPW = rs1("PW")
  %>

% Select Case  Request.Form("CycleNumber")%>


	<%Case "Cycle1"%>


	<% If rs1.EOF = False Then %>
		<% If Request.Form("Remember") = "True" Then
			Response.Cookies("PID") = request("login")
			Response.Cookies("PW") = request("pword")
			Response.Cookies("PID").Expires = Date + 30
			Response.Cookies("PW").Expires = Date + 30
	     End If
		%>

		<% Session("LoggedIn") = True %>
		<% Response.Redirect("Members.asp") %>

	<% Else %>

	<CENTER><H2>Incorrect password.  Please try again.
etc...


here is what it loads on start:

<CENTER><H2>Please enter your Login and Password to access this site.<BR>
	<% Response.Write "SELECT * FROM Members WHERE " & _
	                 "PID='" & Request.Form("login") & "' AND " & _
                	 "PW='" & Request.Form("pword") & "' " %>
	<FORM METHOD="POST" ACTION="memberlogin.asp">
	<INPUT TYPE="hidden" NAME="CycleNumber" VALUE="Cycle1">
	Username: <INPUT TYPE="text" NAME="login" value="<% request.cookies
("PID") %>"><BR><BR>
	Password: <INPUT TYPE="password" NAME="pword" value="<% 
request.cookies("PW") %>"><BR><BR>
	<input type="checkbox" name="Remember" value="True">
		 Remember my Username &amp; Password<br>
	<br>
	<INPUT TYPE="submit" VALUE="SUBMIT">
	<INPUT TYPE="reset" VALUE="RESET"><br>



Can anyone tell me what my problem is here?  It's loading from the 
database, I just can't figure out how to get the cookies loading.  Thanks.

  Return to Index