SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Location
    Ohio
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem logging in with a cookie

    Snippet from normal login:
    Code:
     <!--#include file='includes/dbconnection.inc'--> 
    <!--#include file="includes/md5.asp"-->
    <!--#include file="includes/register.asp"-->
    <% 
    strUserName = Replace(Request.Form("txtUserName"), "'", "''") 
    Set rsCheckUser = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT password, ID, username, admin, suspend FROM tblUsers WHERE username ='" & strUserName & "'"
    rsCheckUser.Open strSQL, adoCon
    This page works perfectly for what I need.

    Later down this page I write a cookie:
    Code:
     'set UserID from dbuserid
    Response.Cookies("User")= rsCheckUser("ID")
    'Set expiration 
    Response.cookies("User").expires = date + 30
    Ok, so I make a dumby page to verify the value in the cookie:
    Code:
     <%
    strID=Request.cookies("User")
    
    response.write "ID=" & strID <br>
    response.write strID
    %>
    Which then displays ID=5
    5 (I wanted to see if I needed the & or not)
    Ok, check the database, yes 5 is my ID in it, so dup the code from login and change to match-vs-cookie:
    Code:
     <!--#include file='includes/dbconnection.inc'--> 
    <!--#include file="includes/md5.asp"-->
    <!--#include file="includes/register.asp"-->
    <%
    strID = Request.cookies("User")
    set rsCheckUser = Server.CreateObject("ADODB.Recordset")
    strSQL = "SELECT password, ID, username, admin, suspend FROM tblUsers WHERE ID =strID"
    rsCheckUser.Open strSQL, adoCon
    Hmm I seem to have recieved an error:
    Code:
     Microsoft JET Database Engine error '80040e10' 
    
    No value given for one or more required parameters. 
    
    /logintest.asp, line 8
    Ok, searched far and wide, seems 90% of my search is saying, not to use a delimiter around strID, wel good cause I aint. The other 10% of the search didn't make much sence to me (alot were links to pages that had that error message...ok I already knew what it looked like, lol)

    If I change line 7 to:
    Code:
     strSQL = "SELECT password, ID, username, admin, suspend FROM tblUsers WHERE ID =5"
    Then it logs me in and works, so my assumption is that =strID" is the problem, but it works on the dumby page for reading the cookie. The only difference between these 2 pages is the &strID". So I put the & in on my page and error:
    Code:
     Microsoft JET Database Engine error '80040e14' 
    
    Syntax error (missing operator) in query expression 'ID = & strID'. 
    
    /logintest.asp, line 8
    Which is because there's nothing before the &, right?

    It worked for awhile Friday and Monday, both times breaking after I tried to add something, so I took out the newly added code and it was still broke.

    I don't know if this means anything but yesterday, I deleted the cookie and tried to recreate a new one (by logging in), I logged in fine but recieved no persistant cookie (had a session cookie though). Confused I repeated this for 20 minutes, then walked away. Came back closed everything, checked and there was no cookie from me, logged back in and it gave me a cookie....Ok no code changes, why didn't it create a cookie for those 20 minutes?

    Is the problem in my code, or on the host?

    Any help would be greatly appreciated, if anything is unclear on this, I appologize, if for some reason I left something important out, just slap me around a bit. Thanks for any help and for taking your time to read this.

  2. #2
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    UK
    Posts
    605
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:

    Code:
     strSQL = "SELECT password, ID, username, admin, suspend FROM tblUsers WHERE ID = " & strID & ";"

  3. #3
    SitePoint Member
    Join Date
    May 2005
    Location
    Ohio
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dan > me

    Thank you very much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •