Results 1 to 5 of 5

Thread: How TO Populate Cookies

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Exclamation

    Hello all. I need help. Here I am querying my DB and assigning the variables to the field I am joining it to.
    Then I am passing the values of the variables and assigning it to the session. Then finally I am plugging in the session values into the cookie I just created.

    Problem: The cookie gets created with the correct fields but not with the values passed down from the variables.

    What am I doing wrong here?


    If Request.Form("txtName") <> "" Then
    SQL = "Select * FROM Register WHERE " & "Register.userID='" & strUserID & _
    "' AND Register.password ='" & strPassword & _
    "' OR Register.FirstName ='" & strFirstName & _
    "' OR Register.LastName ='" & strLastName & _
    "' OR Register.Address ='" & strAddress & _
    "' OR Register.State ='" & strState & _
    "' OR Register.ZipCode ='" & strZipCode & _
    "' OR Register.PhoneNumber ='" & strPhoneNumber & _
    "' OR Register.Email ='" & strEmail & "'"


    cmdDC.CommandText = SQL
    Set RecordSet = Server.CreateObject("ADODB.Recordset")

    RecordSet.Open cmdDC, , 3, 3

    '-- If there is no record found skip this section and display current error page
    If Recordset.EOF Then
    Else
    Session("NewUserID") = strUserID
    Session("Password") = strPassword
    Session("FirstName") = strFirstName
    Session("LastName") = strLastName
    Session("Address") = strAddress
    Session("State") = strState
    Session("ZipCode") = strZipCode
    Session("PhoneNumber") = strPhoneNumber
    Session("Email") = strEmail

    Response.Cookies("ReclaimAmerica").Expires = Date+365
    Response.Cookies("ReclaimAmerica").Secure = FALSE
    Response.Cookies("ReclaimAmerica")("UserID") = Session("NewUserID")
    Response.Cookies("ReclaimAmerica")("Password") = Session("Password")
    Response.Cookies("ReclaimAmerica")("FirstName") = Session("FirstName")
    Response.Cookies("ReclaimAmerica")("LastName") = Session("LastName")
    Response.Cookies("ReclaimAmerica")("Address") = Session("Address")
    Response.Cookies("ReclaimAmerica")("State") = Session("State")
    Response.Cookies("ReclaimAmerica")("ZipCode") = Session("ZipCode")
    Response.Cookies("ReclaimAmerica")("Phone") = Session("Phone")
    Response.Cookies("ReclaimAmerica")("Email") = Session("Email")


    Response.Clear
    Response.Redirect "welcome.asp"
    Response.End

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    need help please!

  3. #3
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810

    Not clear on you problem!

    I don't understand the question!

    If you are putting a variable into a cookie then you can do it direct:
    Code:
    Response.Cookies("ReclaimAmerica")("UserID") = strUserID
    This would be quicker than retrieving it from the session variable first.

    Secondly, why are you using session variables when the same values are in the cookie?

    If you are woried about client side cookies being disabled, don't use them in the first place!
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Thumbs up

    Thanks for the response. What I am trying to do is retreive the users information from the database and create a cookie with that info.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    If the user loses the cookie I have a log in page where they should just log in and then I read the database and then create a new cookie with their personalized info..

    I am trying to use this code to read the DB and assign the values to the variables so I can then create a cookie with the variables:

    If Request.Form("txtName") <> "" Then
    SQL = "Select * FROM Register WHERE " & "Register.userID='" & strUserID & _
    "' AND Register.password ='" & strPassword & _
    "' OR Register.FirstName ='" & strFirstName & _
    "' OR Register.LastName ='" & strLastName & _
    "' OR Register.Address ='" & strAddress & _
    "' OR Register.State ='" & strState & _
    "' OR Register.ZipCode ='" & strZipCode & _
    "' OR Register.PhoneNumber ='" & strPhoneNumber & _
    "' OR Register.Email ='" & strEmail & "'"

Posting Permissions

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



Click Here to Expand Forum to Full Width