473,412 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Can't delete cookie created in Javascript

83
Hi,

I have the following javascript function which creates a cookie

Expand|Select|Wrap|Line Numbers
  1. function setCookie(c_name,value,expiredays)
  2. {
  3.     var exdate=new Date();
  4.     exdate.setDate(exdate.getDate()+expiredays);
  5.     document.cookie=c_name+ "=" +escape(value)                +((expiredays==null) ? "" : ";expires="
  6.         +exdate.toGMTString());
  7. }
  8.  
it works great and if i call...

setCookie ("A2O_list", ' 0 ', 365)

from within in javascript it puts a cookie on my machine as accepted.

However, now i want to destroy the cookie. I can do this with another javascript function BUT for variuos rreasons i need to do it in ASP.

Now, when i call the standard asp routine to destroy the cookie...

Response.Cookies("A2O_list").Expires=Date - 1
OR
Response.Cookies("A2O_list") = ""

the cookie is NOT destroyed !

Can someone pls explain why ?

Thanks in advance
Jun 26 '08 #1
3 2063
acoder
16,027 Expert Mod 8TB
Is there a reason why you're not using JavaScript to delete the cookie? If you want, you could use ASP to generate JavaScript code to delete the cookie.
Jun 26 '08 #2
TimSki
83
Yes, there is a part of the site (part of the login/register) process where i can not be sure that javascript would be enabled.

It just seems strange that asp annot delete a cookie created in javascript. After all it is just a text file sitting in a folder?
Jun 26 '08 #3
acoder
16,027 Expert Mod 8TB
I'm not sure where ASP stores cookies, but cookies are stored in different places even with JavaScript if you use different browsers.

You can't be sure JavaScript is enabled on any page. If you're going to use ASP to delete cookies, you may as well create them using ASP too.
Jun 26 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Phil Powell | last post by:
I am having this problem: My PHP script will set a cookie, it's there in my /Cookies folder. I delete the cookie (I have to for testing purposes, the PHP script I run behaves according to this...
2
by: Michael | last post by:
I am reading and setting a cookie using JavaScript in the BODY onload and onunload events respectively. This works fine. However when I use ASP to set the cookie under some condition where I...
3
by: Warp | last post by:
If I have a cookie with 'key/value' pairs, how would I delete a specific 'key/value' pair while preserving the remaining pairs? I tried to do something like: cookie(key)="" but it didn't seem to...
3
by: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
0
by: Alan Silver | last post by:
Hello, I am having a problem setting and resetting cookies. I'm sure I just doing something really stupid as this is such a basic issue, but I can find any answer. Please can someone help me? ...
6
by: jojowebdev | last post by:
Do javascript cookies REALLY have to be this hard? function setCookie( name, value, expires, path, domain, secure ) { var today = new Date(); today.setTime( today.getTime() ); if ( expires ) {...
24
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How can I see in javascript if a web browser accepts cookies?...
2
by: Josh T | last post by:
As of now I am setting a cookie on my aspx page via javascript, function SetCookie(cookieName, value, minutesToExpire) { ClearCookie(cookieName); var expireDate = new Date(); var...
1
by: TimSki | last post by:
Hi, I've posted this in the javascript forum as well as i guess it's relevant in both. I have the following javascript function which creates a cookie function...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.