文件名称:asp+ 操作Cookie 方法大全
文件大小:3KB
文件格式:TXT
更新时间:2015-10-17 13:20:42
asp+ 操作Cookie 方法大全
/* 豆腐制作 都是精品 www.asp888.net 豆腐技术站 如果转载 请添加这个 版权信息 */ <%@ Page Language="VB" %> [removed] Const COOKIE_NAME As String = "豆腐站点" Const COOKIE_VALUE As String = "http://www.asp888.net" ' 声明 Cookie 对象 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. objCookieObject = New HttpCookie(COOKIE_NAME, COOKIE_VALUE) ' 另外的一种操作Cookie 的 方法 'objCookieObject = New HttpCookie(COOKIE_NAME) 'objCookieObject.Name = COOKIE_NAME 'objCookieObject.Value = "sdsd" ' 设置Cookie 的 过期时间 2001/12/31 23:59:59 objCookieObject.Expires = New DateTime(2001, 12, 11, 23, 59, 59) ' 下面的这些可以不使用 objCookieObject.Domain = "www.asp888.net" 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) ' 删除Cookie 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 lblCookieDetailsName.Text = objCookieObject.Name lblCookieDetailsValue.Text = objCookieObject.Value lblCookieDetailsExpires.Text = objCookieObject.Expires.ToString lblCookieDetailsDomain.Text = objCookieObject.Domain lblCookieDetailsPath.Text = objCookieObject.Path lblCookieDetailsSecure.Text = objCookieObject.Secure.ToString lblCookieDetailsHasKeys.Text = objCookieObject.HasKeys.ToString Else lblCookieDetails.Text = "Cookie Not Set!" lblCookieDetailsName.Text = "" lblCookieDetailsValue.Text = "" lblCookieDetailsExpires.Text = "" lblCookieDetailsDomain.Text = "" lblCookieDetailsPath.Text = "" lblCookieDetailsSecure.Text = "" lblCookieDetailsHasKeys.Text = "" End If End Sub [removed] <html> <head> <title> asp+ 操作Cookie 方法大全 </title> </head> <body>
我们设置的Cookie 的名称是: <%= COOKIE_NAME %>
<form method="post" runat="server">想要看看 Cookie 的当前的各个属性,请点击下面的按钮
Details of:
Cookie属性 | Cookie 的属性Value |
---|---|
名称 | |
Cookie的值 | |
过期时间 | |
所在域 | |
路径 | |
网友评论 |