<script language= "VB" runat= "Server" >
Const cookie_name as String = "Test-cookie-name"
Const Cookie_value as String = "Test-cookie-value"
' Declare our Cookie Object
Dim Objcookieobject as HttpCookie
Sub Btnsetcookie_onclick (Sender as Object, E as EventArgs)
' Create a cookie object-i ' m passing name and value,
' But you can also pass in a name and set the value later.
' IE. Objcookieobject = New HttpCookie (cookie_name)
Objcookieobject = New HttpCookie (cookie_name, Cookie_value)
' We already set these above!
' Objcookieobject.name = Cookie_name
' Objcookieobject.value = Cookie_value
' Normally can leave these alone.
' The defaults'll work fine for most uses.
' Objcookieobject.domain = ' www.domain.com '
' Objcookieobject.path = '/path/'
' Objcookieobject.secure = True
Response.appendcookie (Objcookieobject)
End Sub
Sub Btnremovecookie_onclick (Sender as Object, E as EventArgs)
Objcookieobject = New HttpCookie (cookie_name)
' Expire it on the ' I am ' born just so we ' re sure it ' s a date in the past.
Objcookieobject.expires = New DateTime (1974, 11, 12)
Response.appendcookie (Objcookieobject)
End Sub
Sub Btngetcookie_onclick (Sender as Object, E as EventArgs)
Objcookieobject = Request.Cookies (cookie_name)
If not (objcookieobject = null) Then
Lblcookiedetails.text = Objcookieobject.name
' I ' m ignoring collections. They ' re outside the realm of this basic sample.
' Fyi:additional properties related to Cookie collections:values, Item
End Sub
</script>
<p>
To the cookies ' s current status for you ' ll need to click below. This is because the response
Which adds or deletes the cookie happens after the ' request is ' already done. As such, those changes aren ' t
Available from the request collection until the next request.
</p>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.