问题描述
我正在设置并获取饼干
受保护的子btnSubmit_Click(发件人为对象,e作为EventArgs)处理btnSubmit.Click
尝试
Dim sr As New IO.StreamReader(System.AppDomain.CurrentDomain.BaseDirectory&\\result.txt )
Dim finalresult As Integer = sr.ReadLine
sr.Close()
Response.Write(< script type =' text / javascript'> alert('你的分数是:&finalresult&');< / script>)
Dim sw As New IO.StreamWriter(System.AppDomain.CurrentDomain。 BaseDirectory&\\result.txt)
sw.WriteLine(0)
sw.Close()
Catch ex As例外
结束尝试
结束子
结束类
i am trying to set and get cookie
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
Try
Dim sr As New IO.StreamReader(System.AppDomain.CurrentDomain.BaseDirectory & "\\result.txt")
Dim finalresult As Integer = sr.ReadLine
sr.Close()
Response.Write("<script type='text/javascript'>alert('Your Score is : " & finalresult & "');</script>")
Dim sw As New IO.StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory & "\\result.txt")
sw.WriteLine(0)
sw.Close()
Catch ex As Exception
End Try
End Sub
End Class
推荐答案
Dim cookie As New HttpCookie("NameOfCookie")
cookie.Value = "ValueOfCookie"
Dim expiry As DateTime = DateTime.Now.AddYears(1)
cookie.Expires = expiry
Response.Cookies.Add(cookie)
读取cookie值:
Read cookie value:
Dim cookie As HttpCookie = Request.Cookies("NameOfCookie")
Dim strValue As String = cookie.Value.ToString()
这篇关于如何设置cookie并获取cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!