472,791 Members | 978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 2015
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.