469,954 Members | 1,722 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

Problem with cookies, can't delete cookie

I want to use persistent cookies for my login page. For example, the user
types in his username and password. He can check a box and the system should
remember his username on a next visit. I have the following code, generating
and reading the cookie seems to work fine.

If I uncheck the box, the cookie should be removed or reset. For some
reason, the cookie will not be changed and remains in the cookie folder
(C:\Document and Settings\<user>\Cookies).

<Script runat="server">

Sub Page_Load

getCookie()

End Sub

Sub btnLogin_click(...)
...

If chkPersistCookie.Checked Then
setCookie()
Else
deleteCookie()
End If

End Sub

Sub getCookie()

...

End Sub

Sub setCookie()

...

End Sub

Sub deleteCookie()

Dim objCookie As HttpCookie = Request.Cookies("test")
If Not(objCookie Is Nothing) Then
objCookie.Values.Remove("username")
objCookie.Values.Remove("remember")
objCookie.Expires = DateTime.Now().AddDays(-1)
objCookie.Cookies.Add(objCookie)
End if

End Sub

</Script>

What's wrong with the code? Do I need to check any other permissions?

Thanks,
Urban
Nov 18 '05 #1
0 1552

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by rushik | last post: by
1 post views Thread by Michal A. Valasek | last post: by
1 post views Thread by Rakesh Roberts | last post: by
6 posts views Thread by Stephane | last post: by
6 posts views Thread by Pete Davis | last post: by
1 post views Thread by tshad | last post: by
4 posts views Thread by Water Cooler v2 | last post: by
13 posts views Thread by yawnmoth | last post: by
5 posts views Thread by pbd22 | last post: by
7 posts views Thread by cmrchs | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.