Click to See Complete Forum and Search --> : Retreive Cookies...Not Working


ASPSQLVB
11-01-2009, 12:06 AM
Gang,

I am writing a cookie file to the client then retreiving it and storing the values in a couple of text boxes.

The problem is, I cannot retreive the cookie values. I see the file is in the cookie folder but when I try displaying the values it just doesn't work. Nothing is displayed. I am wondering if there is some other code within the webpage that interferes with the retrieval of cookies.

Below is setting the cookie

Dim Login_Holder,Password_Holder

Login_Holder = Request.Form("Login2")
Password_Holder = Trim(Request.Form("Password2"))

If RememberMe1 = "on" Then

Response.Cookies("Login2") = Login_Holder
Response.Cookies("Password2") = Password_Holder

Dim cookieExpiration1
cookieExpiration1 = DateAdd("d",RS3("LengthofEvent"),RS3("StartDate"))

Response.Cookies("Login2").Expires = cookieExpiration1
Response.Cookies("Password2").Expires = cookieExpiration1

End If



Below is retreiving the cookie

<tr>
<td name="Login" align="middle">
<font color="white" size="3">
<b>Username</b>
</font>
<input name="Login2" size="15" value="<%=Request.Cookies("Login2")%>">
</td>
</tr>

<tr>
<td align="middle">
<font color="white" size="3"><b>Password</b></font>
<input type="Password" name="Password2" size="15" value="<%=Request.Cookies("Password2")%>">
</td>
</tr>

<tr>
<td align="center">
<input type="checkbox" name="RememberMe1" size="10"><font color="white" size="2">Remember Me</font>
</td>
</tr>
<tr>

ASPSQLVB
11-04-2009, 10:29 PM
Here's something strange......I can only Write the requested cookie values immedietly after setting the cookie values. When I try displaying the cookie values in another page, its all blank.

The code below works in one .asp page and not the other. Makes absolutely no sense at all.

Response.Write Request.Cookies("Login2") & " " & Request.Cookies("Password2")
Response.End

ASPSQLVB
11-07-2009, 08:23 PM
Gang,

I have two seprate domains/websites. One website displays the cookie values and the other will not. Both websites use the same login script. The only difference is one website displays the cookie values and the other does not.

I have called my web hosting company to see if there are restrictions on their end. I am waiting to get an answer from them.

At this point I have no idea what could be causing this. Has anyone ever experienced this before ?

verikal
11-09-2009, 04:38 PM
Try setting up cookie path...

Response.cookies("Login2").Path = "/"

ASPSQLVB
11-09-2009, 06:08 PM
Try setting up cookie path...

Response.cookies("Login2").Path = "/"

Hello and Thank You for replying.

So, basically wrting the cookie value to a folder on the server......then retrieving the cookie value and display the values in the text boxes like this:


Response.Cookies("Login2") = Request.Form("Login2")
Response.Cookies("Login2").Path = "/Cookies/Info"
Response.Cookies("Password2") = Request.Form("Password2")
Response.Cookies("Password2").Path = "/Cookies/Info"


After trying the above code, I have noticed no cookies set on the server. I am guess ing this is incorrect ?

verikal
11-09-2009, 08:31 PM
When you display server variables do you see the cookie ?


<table border="1">
<tr>
<td>Server Variable</td>
<td>Value</td>
</tr>
<%
dim x
For Each x In Request.ServerVariables
%>
<tr>
<td><%=x%></td>
<td><%=Request.ServerVariables(x)%></td>
</tr>
<%
Next
%>
</table>


Also try using the main path "/"

ASPSQLVB
11-09-2009, 09:00 PM
I do not see the variable.

The Main path?....like, www.TestSite.com/Folder1/Cookies/test

verikal
11-10-2009, 04:27 AM
No, the main path is just - "/"

Do you see any cookie on the server variables ?

ASPSQLVB
11-10-2009, 10:52 AM
The problem is fixed !!! The cookie values are displayed in the Text Boxes for the Login in.

What a relief !:) The code below fixed the problem.

Response.Cookies("Login2") = Request.Form("Login2")
Response.Cookies("Login2").Path = "/"
Response.Cookies("Password2") = Request.Form("Password2")
Response.Cookies("Password2").Path = "/"

THANK YOU VERIKAL. YOU JUST MADE MY LIFE A LITTLE BIT EASIER !

Now we can move forward.

Much appreciated !

Ken

verikal
11-10-2009, 11:33 AM
I'm glad it worked out for you.