p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Professional (http://p2p.wrox.com/forumdisplay.php?f=63)
-   -   Cookies (http://p2p.wrox.com/showthread.php?t=43104)

hastikeyvan May 28th, 2006 01:54 AM

Hello all
I'm trying to write cookie for my login page.that knows the user and show welcome in the next pages.i did it befor but it doesn't work now.
in my login page i put this code:

response.cookies("UserInformation")("name")=reques t("txtUser")
in which txtUser is my UserName field in login page.
and in other pages I used response.write that cookie
would you please tell me where is the problem?

erobb May 28th, 2006 08:27 AM

Have you tried hard coding it to make sure your form request is setting the cookie properly?

response.cookies("UserInformation")("name")="A User"

response.write request.cookies("UserInformation")("name")


hastikeyvan May 28th, 2006 08:38 AM

i tried response.cookies("UserInformation")("name")="my name"
and it works.but when i use the form fields it doesn't work?do you know where is the problem?
thank you

erobb May 28th, 2006 09:17 AM

response.write request.form("txtUser") &"<-- txtUser"

What value is returned? I think the info from the form is not being returned to the cookie so the cookie is always blank. Its setting the cookie properly just the cookie always has a value of nothing.

If this is the case you want to confirm that txtUser is in fact the name of the textbox you are using.


hastikeyvan May 29th, 2006 01:00 AM

You're right.the cookie doesn't get the value of txtUser.i changed my code to this kind but it didn't work:
<script for="txtUser" language="vbScript" event="onkeypress">
response.cookies("UserInformation")("Name")=docume nt.form1.txtUser.Value
in which form1 is my form name.
can we set the cookie value in this way????
I would be very happy if you help me.
thank you for your replies

erobb May 29th, 2006 07:36 AM

will this work? I suspect the code you currently have will not work browsers other than ie the code below will work with all browsers.

<form action="page2.asp" method="post">
<input name="txtUser" type="text">
<input type="submit" name="Submit" value="Submit">

response.cookies("UserInformation")("name")=reques t("txtUser")


All times are GMT -4. The time now is 02:09 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.