用cookies来保存时没有值?!
看别人的程序中是这样的:(在保存的时候)
Response.Cookies("userinfo")("UserName")=trim(Request.Form("username"))
Response.Cookies("userinfo")("Useremail")=trim(Request.Form("email"))
Response.Cookies("userinfo").Expires = now() + 365
我将其改为
Response.Cookies("noall")("txtname")=trim(Request.Form("txtname"))
Response.Cookies("noall")("txtemail")=trim(Request.Form("txtemail"))
Response.Cookies("noall").Expires = now() + 365
再将其取出来,竟然是空值.
取值:
<td align="left"width="10%"><input type="text" name="txtname" value="<%=request.cookies("noall")("txtname")%>" maxlength="16" size="12"><font color=red>*</font></td>
<td align="right" width="15%"><font size=2>Email:</font></td>
<td align="left" width="29%"><input type="text" name="txtemail" value="<%=request.cookies("noall")("txtemail")%>" maxlength="30" size="20"><font size=2 color=green></td>
问题点数:30、回复次数:11Top
1 楼noallasp()回复于 2001-06-21 10:11:00 得分 0
TQTop
2 楼11830(其其)回复于 2001-06-21 10:20:00 得分 3
这样试试
<td align="left"width="10%"><input type="text" name="txtname" value=<%=request.cookies("noall")("txtname")%> maxlength="16" size="12"><font color=red>*</font></td>
<td align="right" width="15%"><font size=2>Email:</font></td>
<td align="left" width="29%"><input type="text" name="txtemail" value=<%=request.cookies("noall")("txtemail")%> maxlength="30" size="20"><font size=2 color=green></td>
Top
3 楼fengyang(流浪黄蜂者)回复于 2001-06-21 10:55:00 得分 3
改成这样:
Response.Cookies("noall")("txtname")=trim(Request("txtname"))
Response.Cookies("noall")("txtemail")=trim(Request("txtemail"))
Response.Cookies("noall").Expires = now() + 365
Top
4 楼noallasp()回复于 2001-06-21 12:54:00 得分 0
都不行啊.Top
5 楼shuyi(舒易)回复于 2001-06-21 13:03:00 得分 4
写进去的时候response.write一下看看是否真的写到cookies里面Top
6 楼noallasp()回复于 2001-06-21 13:15:00 得分 0
没错,写的时候就是为空啊,我有试过.
response.write response.coolies("noall")("txtname")没有东西出现.
就是为什么存不进去呢?Top
7 楼noallasp()回复于 2001-06-21 14:39:00 得分 0
TQTop
8 楼sanjianxia(三剑侠)回复于 2001-06-21 16:36:00 得分 10
cookies在数据存储时,一定要在第一个<html>语句之间,否则就会出错存储时为空的现象。我第一次用cookies时也和你一样出现同样的问题.Top
9 楼7710703(易水寒)回复于 2001-06-21 16:40:00 得分 0
我感觉应该是程序中其他地方的毛病,把整个页面贴出来看看Top
10 楼7710703(易水寒)回复于 2001-06-21 16:45:00 得分 10
sanjianxia(三剑侠)说的对,但是如果在页面第一行加入response.buffer=true,只要不进行刷新和跳转在任何地方都可以写入cookies.Top
11 楼noallasp()回复于 2001-06-22 12:54:00 得分 0
sanjianxia(三剑侠):是啊,就是这样子,我把它放在另外一个asp文件的第一行,就可以了
本来我是本页跳转到本页进行保存,现在用另外一个文件进行保存就可以了。
7710703(我是一只老菜鸟):我设response.buffer=false啊。就是在保存跳转时写入cookiesTop




