Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - asp deleting cookies
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

asp deleting cookies

 Post Reply Post Reply
Author
riya_singtel View Drop Down
Newbie
Newbie
Avatar

Joined: 14 March 2005
Location: India
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote riya_singtel Quote  Post ReplyReply Direct Link To This Post Topic: asp deleting cookies
    Posted: 30 March 2005 at 9:57pm
I am working on cookies in asp and I need an option to delete the cookie when a button is clicked. So i just write an empty string in it.
 
I set the cookies as:
Response.Cookies("name")="Henry"
 
The code for button is:
<INPUT type="button" value="Remove" OnClick="removeCookie">
 
The code for deleting the value is:
<SCRIPT language="VBSCRIPT">
Sub RemoveCookie
     document.cookie = "name="
End Sub
</SCRIPT>
 
However I realise that this creates a duplicate cookie named name without any value( Checked it by retrieving all cookies).I guess one copy is created at the client and other at the server which gives me erroneous results when i access the value of the cookie later.
 
I can reset the value of the cookie uisng Response.Cookies but i do not know how to implement it on  a button click.
 
Any proposed solns shall be appreciated.
thanks
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 30 March 2005 at 11:09pm
Google is your friend

http://www.webreference.com/js/column8/functions.html

/*
name - name of the cookie
[path] - path of the cookie (must be same as path used to create cookie)
[domain] - domain of the cookie (must be same as domain used to
create cookie)
path and domain default if assigned null or omitted if no explicit
argument proceeds
*/

function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

Back to Top
riya_singtel View Drop Down
Newbie
Newbie
Avatar

Joined: 14 March 2005
Location: India
Status: Offline
Points: 30
Post Options Post Options   Thanks (0) Thanks(0)   Quote riya_singtel Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2005 at 4:29am

thanks...i'll try it out and let u know..



Edited by riya_singtel - 31 March 2005 at 8:16pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.