Forum Moderators: open

Message Too Old, No Replies

Cookies, Cookies

used to love them, now not so much

         

Blelisa

3:21 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



I am getting so aggravated! I have been trying to work out this code and it won't work.

First, should my code be in my form page or my asp page to tell the system to store the cookies if the checkbox is checked? I currently have it on my asp page that processes my form.
The code I have is:
If Request.Form("cbxcook") = "checkbox" Then'
Response.Cookies("ckusername") = Request.Form("username")
Response.Cookies("ckusername").Expires = #1/1/2010#
Response.Cookies("ckPassword") = Request.Form("password")
Response.Cookies("ckPassword").Expires = #1/1/2010#
End If

cbxcook being my name of my checkbox.

IF I run this asp I do not receive any error messages at all.

Than I run a separate asp page with this code to pull up the store cookies:
<%
Name = Request.Cookies("ckusername")
%>
<HTML>
<BODY>
Hi there <%=name%>!
</BODY>
</HTML>

Is my error on my asp page generating the cookies, or the asp page reading the cookies?

dotme

4:20 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



Blelisa
We need the error - what are you seeing?

BTW, cookie for a password not a good idea. Here's a thought - Use that randomize autonumber feature in access. After you stuff in the username and password on registration, it will create a random number.

When a user logs in, grab that random number and set that as a cookie for the session. Makes looking up their info a snap, and you don't store their username and password in their cookie file.

Oh -
If Request.Form("cbxcook") = "checkbox" Then'

If there's really a ' at the end of that line, remove it :-)

Blelisa

4:41 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



Hi Dotme.
I am not getting any errors at all.
When I go to try to read the cookies, it does not read them at all.
I know putting passwords in a cookie are not a good idea but this is just for practice, and I would like to see if I can get this too work.

Jimmy Turnip

5:20 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



You say 'run a seperate asp page'. Is this on the same domain as the page that created the cookie? It has to be to work.

You could also try Response.Cookies("ckusername").Expires = #May 10,2010# or something as well.

dotme

6:00 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



Your code looks good - you should set the cookies on the ASP page that the form POSTs to, so you are on the right track there also.

Remember that IE has privacy settings and looks for a P3P policy if security levels are set to do so.

After you post to your ASP page, look at the bottom of the IE browser window and see if there's a red No Entry symbol. If there is, click it and tell IE to allow cookies for that site. Then try again. That should tell you if your code is all good. P3P is a can of worms, but you will probably need it to guarantee that your end users can log in.

carguy84

4:52 am on Feb 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



adding on to what dotme said about storing passwords in cookies, don't practice with it, otherwise it will be habit forming :)

but if you must...try something like this, see if it works:

With Response
.Cookies("User")("username") = username
.Cookies("User")("password") = password
.Cookies("User").Domain = "www.example.com"
.Cookies("User").Expires = "1/1/2006
End With

then on another page:
<%=Request.Cookie("User")("username")%>

If that doesn't work, make sure your server supports ASP :)

Chip-