Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies

Status
Not open for further replies.

cabobound

Programmer
Jul 11, 2007
80
0
0
US
I am using cookies for a login and to keep track of login data such as what office they are in. All of a sudden this morning with no changes the login page is not keeping track of the cookies. The client is remote and the in-house dev site works fine so I know its not the workstation settings.

IE. I can login to the dev site on my w/s but cannot when I try on the client.

I have tested the code and gotten it to go through the loop, it simply does not save the cookies. Any ideas?

If uRst.eof=False Then
Response.Cookies("uname")=uRst("Username")
Response.Cookies("user_level")=uRst("level")
Response.Cookies("uoffice")=uRst("Office")
Response.Cookies("uadmin")=uRst("admin")
Response.Cookies("login")="t"
If Request.Cookies("uname")="ainquiry" and Request.Cookies("uoffice")="Assessor" Then
Response.Redirect "inquiry/menu.asp"
End If
Response.write "Cookies"
Response.Redirect "menu.asp"
End If

kt
 
The browser on the workstation of the client will need to have cookies enabled.
 
they are. i know this because i can login to on my in-house dev site and not the client site. They are set on my w/s so that cant be the problem. Correct?
 
So you're logging in to both sites using your workstation? I misunderstood then. I thought you were attempting to log in to the in-house dev site from the client's workstation.
 
I would begin debugging that loop to see if uRst has any real values. Perhaps the in-house dev site is set up with dummy data that allows you to log in but the client site is still empty? For debugging, I'd replace all of the Response.Cookies statements with Response.Write statements and see what we're working with.
 
I thought of that in line for lunch LOL. I am getting the correct values that are in the database.
 
Any progress on this?

Since you've verified the values are being retrieved properly, I'd move into Response.Write of the Response.Cookies values to make sure they aren't saving.
 
I have written them to the screen. So they are being read from the database and used to print on the screen.
 
Try looping through the cookies just for more debugging fun:

Code:
If uRst.eof=False Then
    Response.Cookies("uname")=uRst("Username")
    Response.Cookies("user_level")=uRst("level")
    Response.Cookies("uoffice")=uRst("Office") 
    Response.Cookies("uadmin")=uRst("admin") 
    Response.Cookies("login")="t"
    'If Request.Cookies("uname")="ainquiry" and Request.Cookies("uoffice")="Assessor" Then 
        'Response.Redirect "inquiry/menu.asp" 
    'End If
''''''''''   grabbed from w3schools '''''''''''''
    dim x,y
    for each x in Request.Cookies
      response.write("<p>")
      if Request.Cookies(x).HasKeys then
        for each y in Request.Cookies(x)
          response.write(x & ":" & y & "=" & Request.Cookies(x)(y))
          response.write("<br />")
        next
      else
        Response.Write(x & "=" & Request.Cookies(x) & "<br />")
      end if
      response.write "</p>"
    next
    Response.write "Cookies"
    'Response.Redirect "menu.asp"
End If
 
Then there is the outside chance that you need to type the cookies:
Code:
If [COLOR=red]CStr([/color]Request.Cookies("uname")[COLOR=red])[/color]="ainquiry" and [COLOR=red]CStr([/color]Request.Cookies("uoffice")[COLOR=red])[/color]="Assessor" Then
 
I am running firefox and not sure if this is not a firewall issue at this time! Although I do find it odd that the code would still go through the loop, grab data from the database, print it to screen and yet not create the cookies.
 
It would go through the loop because the loop is based on the database, not the cookies. The part that depends on the cookies is the comparison portion and that's why I said it might need to be typed in order for them to equal. It might be saving the cookies...you printed to the screen the database values. You never said that you printed to the screen the cookies (the example I provided from w3schools). It would help if you showed what you've done as part of your debugging.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top