以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  内部函数,使用StringBuilder写html+css+js网页,cookie可以设置时间参数吗?也就是可以设置第三个参数么?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=153894)

--  作者:zhangjian222200
--  发布时间:2020/8/26 19:38:00
--  内部函数,使用StringBuilder写html+css+js网页,cookie可以设置时间参数吗?也就是可以设置第三个参数么?
如题

AppendCookie(Name, Value, Expires)

Name:   Cookie名称
Value:  Cookie值
Expires:可选参数,整数型,用于设置Cookie的有效时间,单位是分钟,如果不设置,关闭浏览器后Cookie将失效。
[此贴子已经被作者于2020/8/26 19:41:46编辑过]

--  作者:有点蓝
--  发布时间:2020/8/27 8:58:00
--  
您自己都把帮助贴出来了,还要问,什么地方看不懂?

Expires:可选参数,整数型,用于设置Cookie的有效时间



--  作者:zhangjian222200
--  发布时间:2020/8/27 9:09:00
--  
Dim wb As New WeUI
Dim cnt As  Integer = 1
If
 e.Cookies.ContainsKey("count"\'如果存在名为countCookie
    Integer.TryParse(e.Cookies("count"),cnt) \'
提取cookie的值并转换为整数
    cnt = cnt + 1

End
 If
wb
.AppendCookie("count",cnt) 帮助上是wb.AppendCookie
wb
.InsertHTML("您这是第" & cnt & "次访问!")
e
.WriteString(wb.Build)

下面StringBuilder页面
Dim e As RequestEventArgs = args(0)

Dim sb As New StringBuilder
sb
.AppendLine("<!doctype html>")
sb
.AppendLine("<html>")
sb
.AppendLine("<head>")
sb
.AppendLine("<meta charset=\'utf-8\'>")
sb
.AppendLine("<title>表单</title>")
sb
.AppendLine("</head>")
sb
.AppendLine("<body>")


wb.AppendCookie("number", 100, 100) \'这样测试不成功,应该怎么办?


改成


sb.AppendCookie("number", 100, 100) ’这样也不行


sb.AppendLine("<form enctype=\'multipart/form-data\' method=\'post\' id=\'form1\' name=\'form1\'>")
sb
.AppendLine("产品: <input name=\'cp\' id=\'cp\'><br/><br/>")
sb
.AppendLine("客户: <input name=\'kh\' id=\'kh\'><br/><br/>")
sb
.AppendLine("雇员: <input name=\'gy\' id=\'gy\'><br/><br/>")
sb
.AppendLine("单价: <input Type=\'number\' name=\'dj\' id=\'dj\'><br/><br/>")
sb
.AppendLine("折扣: <input Type=\'number\' name=\'zk\' id=\'zk\' min=\'0\' max=\'0.15\' step=\'0.01\'><br/><br/>")
sb
.AppendLine("数量: <input Type=\'number\' name=\'sl\' id=\'sl\'><br/><br/>")
sb
.AppendLine("日期: <input Type=\'date\' name=\'rq\' id=\'rq\'><br/><br/>")
sb
.AppendLine("<input Type=\'submit\' name=\'Sumbit\' id=\'Sumbit\' value=\'确定\'>")
sb
.AppendLine("</form>")
sb
.AppendLine("</body>")
sb
.AppendLine("</html>")
e
.WriteString(sb.ToString)

[此贴子已经被作者于2020/8/27 9:15:18编辑过]

--  作者:有点蓝
--  发布时间:2020/8/27 9:33:00
--  
这种用法无法使用weui了,需要自己使用原生的用法自己写js控制

https://www.runoob.com/js/js-cookies.html

https://developer.mozilla.org/zh-CN/docs/Web/API/Document/cookie