Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unhappy Unanswered: help reading a cookie

    I am trying to create a login page for the first time, I have a login page, validate login page and if the password is correct it takes me to the first page.

    I have customized this code someone else created,but what I have a problem with now is I need to log who submitted that data and that is why I am trying to read UserName cookie so I can later match that data.

    This is the error I get which is telling me that it is reading the cookie since this is the UserName I am logging in with
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'boxhill'.

    but I can't see what is wrong, and there is not much out there for this kind of error.

    So I can login successfully but now i need to read and dispaly that cookie and then insert the value of the cookie but,but don't worry about that now, just trying to give you the full picture.

    So this is the code for reading the cookie

    Dim myCon
    Dim rs

    set myCon = Server.CreateObject("ADODB.connection")
    set rs = Server.CreateObject("ADODB.recordset")

    call myCon.Open(Application("MM_Shipment_ConnectionSTRI NG"))
    call rs.Open("SELECT UserName FROM Logins " & _
    " WHERE UserName=" & Request.Cookies("Login"), myCon)
    Response.Write(rs("UserName"))
    call rs.Close

    Could somebody help me with this please.

    thanks a lot

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    You need single quotes around the value returned from the cookie since it's a string:

    call rs.Open("SELECT UserName FROM Logins " & _
    " WHERE UserName='" & Request.Cookies("Login") & "'", myCon)
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Thumbs up

    Thanks a lot, that worked like a dream.

    This is the first time I am working with Cookies so I am very excited to learn something new.

  4. #4
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    Ok, so I was able to create the login,validate the login and get taken to a page where users enter and submit data and on that page I am also dispalying a UserName and also submitting the user name so I can later on match up who submitted what and where was it coming from,but there is a but.

    When data is submitted by clicking on submit it takes me to Save.asp and then I redirect the page after 2 seconds to go back to First.asp page where users can enter more recrods if needed,but the value of my cookie is not disaplyed any more,so technically they are still logged in but I need to be able to dispaly the cookie which is a UserName all the time since I need them to submit that UserName for every record they enter.

    So this is just how I display the UserName

    set myCon = Server.CreateObject("ADODB.connection")
    set rs = Server.CreateObject("ADODB.recordset")
    call myCon.Open(Application("MM_Shipment_ConnectionSTRI NG"))
    call rs.Open("SELECT UserName FROM Logins " & _
    " WHERE UserName='" & Request.Cookies("Login") & "'", myCon)
    Response.Write(rs("UserName"))
    call rs.Close

    and for saving the Cookie value, it is just part of my insert statement.


    So what do I need to do to get the Cookie value=UserName to stay displayed when the page is redericted after users submitted their first record.

    Hope this makes sense and somebody can help me.

    Thanks a lot



    PLEASE IGNORE I JUST HAD A LITTLE MENTAL MIX UP!
    Last edited by zobernjik; 11-10-04 at 22:40. Reason: posted by mistake

Posting Permissions

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