Cookies Handling

Write Cookie

[VB]




Dim cookie As HttpCookie = New HttpCookie("UID")


cookie.Value = "myid"


cookie.Expires = #10/12/2010#


Response.Cookies.Add(cookie)


cookie = New HttpCookie("PASS")


cookie.Value = "mypass"


cookie.Expires = #10/12/2010#


Response.Cookies.Add(cookie)





Read & display all the cookies and its values in Listbox1 control

[VB.NET]



Dim cookieCols As New HttpCookieCollection


cookieCols = Request.Cookies


Dim str As String


For Each str In cookieCols


ListBox1.Items.Add("Cookie: " + str)


ListBox1.Items.Add("Value:" & _


Request.Cookies(str).Value)


Next





Delete Cookies

[VB.NET]


Dim cookieCols As New HttpCookieCollection


cookieCols = Request.Cookies


Request.Cookies.Remove("PASS")


Request.Cookies.Remove("UID")

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.