473,386 Members | 1,830 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,386 software developers and data experts.

? Deleting All of My Site's Cookies / Using Wildcards With Cookie

Hi,

I'm using JavaScript and Cookies for some customization in a web page.
There may be several values in the cookie with names that are not known at
runtime. I need a way of deleting them.

For example, if my site is www.test.com and the cookie contains:

label1
fob
....
*

name1
foo
....
*
name2
bar
....
*
name3
baz
....
*

and so on, then I would write a function that simply deletes these values
with a loop that counts off name1, name2, name3, et cetera. Unfortunately
my cookie will use different labels, not name1, name2, name3..., in fact I
have no way of knowing exactly what they will be called beforehand although
they will have some things I can predict.

Can I use wildcards in the value-name, eg. in the above example, could I
delete "name*" or "*1"? Alternatively, is there a way to just delete ALL
values in the cookie?
Thanks.

--
news <.> alec <@> synetech <.> cjb <.> net
Jul 23 '05 #1
14 3211
Oh, and I know I have to set the value to expire to delete it. What I'm
looking for is a way to expire unknown values (names).
--
news <.> alec <@> synetech <.> cjb <.> net

Jul 23 '05 #2
Alec S. wrote:
Oh, and I know I have to set the value to expire to delete it. What I'm
looking for is a way to expire unknown values (names).


Set the expiration date on the cookie to a past date, the cookie will be
expired and it will be gone. Then, you reset the cookie with the data
you want.

--
Randy
Jul 23 '05 #3
Randy Webb wrote on 17 apr 2005 in comp.lang.javascript:
Alec S. wrote:
Oh, and I know I have to set the value to expire to delete it. What I'm
looking for is a way to expire unknown values (names).


Set the expiration date on the cookie to a past date, the cookie will be
expired and it will be gone. Then, you reset the cookie with the data
you want.


You will have to trust the client time not being set in the past.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #4
Like I said, I already know how to delete a cookie-value whose name I know.
I need a way of deleting a cookie-value whose name I DON'T know.
--
news <.> alec <@> synetech <.> cjb <.> net
Jul 23 '05 #5
Alec S. wrote on 17 apr 2005 in comp.lang.javascript:
Like I said, I already know how to delete a cookie-value whose name I
know.
This is usenet, please quote, if you are anwering someone.
I need a way of deleting a cookie-value whose name I DON'T know.


You should know their names since you set them.

=================

With serverside ASP [sorry: vbs here] I can read them all:

Cookies Variables <br>
<% For each d in Request.Cookies %>
<%=d%>
=
<%=Request.Cookies(d)%>
<br>
<% Next %>

And then set their content on "" and the expiry on 1 jan 1970

Serverside javascript goes about the same,
but with clientside javascript I doubt, if it is possible.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #6
> This is usenet, please quote, if you are anwering someone.

I didn't quote because I was replying to someone who replied to someone who
replied to me. Should I cut and paste multiple quotes, especially if they
are long? Most, if not all newsreaders these days display messages in a
"thread" which makes it easy enough to find the reference.

You should know their names since you set them.


Think about it this way. I have two text boxes in a form. The user enters
some text in them. I take that text from the first box and set a cookie
using that user-entered text as the name/label passing the text from the
second box as the value.

This isn't exactly the way I'm doing it but it's close enough to explain why
I don't know the name of the cookie. I need either a way of deleting all
cookies made at my site, simply deleting the whole cookie file associated
with my site, or some way of using wildcards—say for example if the user
must enter a username like 1234Blah where the 1234 is always the same and
the Blah is different.
--
news <.> alec <@> synetech <.> cjb <.> net
Jul 23 '05 #7
Alec S. wrote on 18 apr 2005 in comp.lang.javascript:
This is usenet, please quote, if you are anwering someone.


I didn't quote because I was replying to someone who replied to
someone who replied to me. Should I cut and paste multiple quotes,
especially if they are long? Most, if not all newsreaders these days
display messages in a "thread" which makes it easy enough to find the
reference.


Please dont try to reinvent netiquette.
You should know their names since you set them.


Think about it this way. I have two text boxes in a form. The user
enters some text in them. I take that text from the first box and set
a cookie using that user-entered text as the name/label passing the
text from the second box as the value.

This isn't exactly the way I'm doing it but it's close enough to
explain why I don't know the name of the cookie.


Cookie handling is versatile enough not to be used this way

Strange you give so much room to these two sentences of mine
and do not address the real answer I gave.

Prossibly because you did not quote, you forgot that answer? ;-}

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #8
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Randy Webb wrote on 17 apr 2005 in comp.lang.javascript:
Alec S. wrote:
Oh, and I know I have to set the value to expire to delete it. What I'm looking for is a way to expire unknown values (names).


Set the expiration date on the cookie to a past date, the cookie will be
expired and it will be gone. Then, you reset the cookie with the data
you want.


You will have to trust the client time not being set in the past.


and
I need a way of deleting a cookie-value whose name I DON'T know.


You should know their names since you set them.

There, I quoted, adding a lot more text to download which is annoying for
dial-up users. I am not reinventing netiquette, but using guidelines that
many people—other than yourself—follow.
Either way, you did not help by saying that I should know the names nor by
saying that I need to trust the user's system clock. If you are feeling
hostile, judgmental, and critical and have no interest in helping then you
need not answer, I am sure there will be someone else who will give an
answer politely—and non-accusatorially—one way or another. It's so annoying
that there are grouchy people like you trolling everywhere.
--
news <.> alec <@> synetech <.> cjb <.> net
Jul 23 '05 #9
Alec S. wrote on 19 apr 2005 in comp.lang.javascript:
Either way, you did not help by saying that I should know the names
nor by saying that I need to trust the user's system clock.


You will be the judge to if it helps you,
but both advises were made in an effort to help you.

The same goes for my final anwer to your OQ,
which you repeatedly forgot to address.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #10
I addressed both of your answers:
1: > You should know their names since you set them.

I DON'T know the name. I gave a clear example why I would not know them.
2: > You will have to trust the client time not being set in the past.

I already know that to delete a cookie you have to expire it. That is NOT
what I asked.

I don't know how I can explain the question or why your answers were not
helpful any more clearly. Perhaps you should take your infinite knowledge
along with your demeanor elsewhere. There are plenty of places on the
Internet where irritable people can argue. People like you are anything BUT
helpful; if someone asks a question you freak out and call them stupid
because they don't know what you know which is exactly why they asked in the
first place. I just pray that you are not a teacher.

--
news <.> alec <@> synetech <.> cjb <.> net
Jul 23 '05 #11
Alec S. wrote on 19 apr 2005 in comp.lang.javascript:
I don't know how I can explain the question or why your answers were
not helpful any more clearly. Perhaps you should take your infinite
knowledge along with your demeanor elsewhere. There are plenty of
places on the Internet where irritable people can argue. People like
you are anything BUT helpful; if someone asks a question you freak out
and call them stupid because they don't know what you know which is
exactly why they asked in the first place. I just pray that you are
not a teacher.


Oh, oh, are we touchy.

Alec, this is usenet and not a paid helpdesk.

You cannot insist that responses to your questions must be helpfull to you
[or in fact you can, you can do what you like on usenet, but it would be an
unreasonable act]

So trying to explain why you find the responses not helpful, while I put to
you they were ment to be helpful, is not ferry useful, as I never insisted
you should find them so.

Saying that I must go away because you don't rate my answers high enough is
plainly silly, since if you have a problem, don't expect others to take the
consequences thereoff.

I did not call you stupid, perhaps you are projecting you own selfesteem?

I will now stop answering you.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #12
"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
The same goes for my final anwer to your OQ,
....

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn*******************@194.109.133.29... Oh, oh, are we touchy......


I guess that wasn't so final after all.
--
news <.> alec <@> synetech <.> cjb <.> net
Jul 23 '05 #13
On Sun, 17 Apr 2005 05:06:09 +0200, Alec S. <a@a.com> wrote:
I'm using JavaScript and Cookies for some customization in a web page.
There may be several values in the cookie with names that are not known
at runtime. I need a way of deleting them.


Easy: document.cookie gives you all the cookie names.

var cookieArray = document.cookie.split( ';' );

for( var i=0; i<cookieArray.length; i++ ){

nameValueArray = cookieArray[ i ].split( '=' )
// now cookie name is nameValueArray[ 0 ],
//set it with expiry in the past
document.cookie = nameValueArray[ 0 ] + ';expires=Sun, 17 April 2005
05:06:09'
}
(Caveat: I didn't bother doublechecking if the date format is correct for
cookies.)

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #14
Hallvord R. M. Steen wrote:
Alec S. wrote:
I'm using JavaScript and Cookies for some customization in a web
page. There may be several values in the cookie with names that are
not known at runtime. I need a way of deleting them.
Easy: document.cookie gives you all the cookie names.


document.cookie - _may_ give you all the cookie names.

Internet "privacy" provided by content-inserting/re-writing proxies
often included a facility intended to prevent the client-side scripting
of cookies, that works by replacing the string "cookie" with an (any)
alternative wherever it appears in client-side script source code. The
expected outcome of this would be that - document.cookie - would return
undefined (having been transformed into - document.ignore - (for
example) by the proxy).
var cookieArray = document.cookie.split( ';' );

<snip>

The result of the actions of this type of proxy is that code that
assumes that - document.cookie - will return a string, and then goes on
to call a String object method, will error-out. Potentially taking out
related code that may not actually depend on successful cookie
interactions (or probably does not need to be designed to be dependent
on cookie use).

Applying a type-converting test to result of reading - document.cookie -
prior to applying any other operations to the resulting value avoids the
problem, and allows scripts to handle the unavailability of cookies
without erroring:-

var cky;
if((cky = document.cookie)){
... // document.cookie returned a value that type-converts
// to true, so not undefined or an empty string (which
// isn't worth reading anyway).
}

Richard.
Jul 23 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aki Niimura | last post by:
Hello everyone, I have been trying to write a Python script to access a Web site. I'm currently having a problem completing my script because the contents I would like to access in the Web...
1
by: Michal A. Valasek | last post by:
Hello, I have problem deleting cookies and cookies values (using framework version 1.1 on W2003). When I try to remove entire cookie, by calling Response.Cookies.Remove("Test"), nothing...
5
by: Tony Pino | last post by:
Hi, Lets say there's a web site with simple authentication. It asks you to type a uname/password into a couple text boxes, and then it gives you a cookie and you're logged in for 20 minutes or...
2
by: James | last post by:
Help! I've made a cookie with a key called 'List' and subkey 'item3' and assigned it a value of "3" Response.Cookies("List")("item3")="3" How do I now delete the subkey "item3" without...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, if I have this cookie header in a response: Set-Cookie: CookieName=; path=/;expires=01-Jan-1999 00:00:00 GMT the...
4
by: macro | last post by:
when I use HttpWebRequest with CookieContainer object that handles cookies, i make more than one request and needs to handle cookies being added and removed between requests, just like a regular...
1
by: sameer | last post by:
Hi all, Environment : ASP.NET I am using cookies to store some data. this is done in a class which is called by a web page CookieCreate.aspx. Here is a little bit of code of how i create the...
1
by: onceuponapriori | last post by:
Greetings gents. I'm a Railser working on a django app that needs to do some scraping to gather its data. I need to programatically access a site that requires a username and password. Once I...
3
by: Gregory A Greenman | last post by:
I'm trying to screen scrape a site that requires a password. If I access the site's login page in my browser and view the source, I see that it does not contain a viewstate. When my program...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.