473,472 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cookies duplicating themselves

Hi everyone

I'm using v 2.0 of the framework with C# and am developing a web
application.

I am finding that my cookie names are duplicating themselves over and
over again, for example when I write out all the cookie keys and
values, I am getting the following:

CookieA: Apple
CookieB: Banana
CookieC: Carrott
CookieA: Apple
CookieB: Banana
CookieC: Carrott

I don't understand why this is happening - but I feel there may be
some of you out there that know exactly what has caused this
problem... or at least I hope!

Any pointers are most appreciated.

Many thanks

Darren

Mar 20 '07 #1
3 1290
What method are you using to add the cookies to the cookie collection? Are
you using insert? If so then it may simply be appending the added cookie(s)
onto the existing collection. Before, you may check to see if CookieA exists
at some ordinal position by doing something like,
Resposnse.Cookie["CookieA"] = , some cookie
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

<Da**************@gmail.comwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
Hi everyone

I'm using v 2.0 of the framework with C# and am developing a web
application.

I am finding that my cookie names are duplicating themselves over and
over again, for example when I write out all the cookie keys and
values, I am getting the following:

CookieA: Apple
CookieB: Banana
CookieC: Carrott
CookieA: Apple
CookieB: Banana
CookieC: Carrott

I don't understand why this is happening - but I feel there may be
some of you out there that know exactly what has caused this
problem... or at least I hope!

Any pointers are most appreciated.

Many thanks

Darren

Mar 20 '07 #2

Here is a cookie wrapper I had:
public static void SetCookieValue(Page p, string cookieName, string
cookieValue, string subKey, TimeSpan expiresTimeSpan)

{

bool subKeyWasSupplied = false;

if (null != subKey)

{

if (subKey.Length 0)

{

subKeyWasSupplied = true;

}

}

_currentTimeSpan = expiresTimeSpan;

if (p.Request.Cookies[cookieName] == null)

{

CreateCookie(p, cookieName);

}

HttpCookie aCookie = p.Request.Cookies[cookieName];

if (subKeyWasSupplied)

{

aCookie.Values[subKey] = cookieValue;

}

else

{

aCookie.Value = cookieValue;

}

aCookie.Expires = DateTime.Now.Add(_currentTimeSpan);

p.Response.Cookies.Add(aCookie);

}

<Da**************@gmail.comwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
Hi everyone

I'm using v 2.0 of the framework with C# and am developing a web
application.

I am finding that my cookie names are duplicating themselves over and
over again, for example when I write out all the cookie keys and
values, I am getting the following:

CookieA: Apple
CookieB: Banana
CookieC: Carrott
CookieA: Apple
CookieB: Banana
CookieC: Carrott

I don't understand why this is happening - but I feel there may be
some of you out there that know exactly what has caused this
problem... or at least I hope!

Any pointers are most appreciated.

Many thanks

Darren

Mar 20 '07 #3
Hi Mark, sloan

I'm using Response.Cookies.Set - does that make any difference?

I'm also doing the checks to see if the cookies already exist but
still not working.

The really strange thing is that on my local machine I new have this
working fine (again) - but when I publish to my live server, cookies
are dropping at random.

I've tried adding a loop in my master page to reset ALL the cookies on
Page_Load but this doesn't even seem to get around the problem!

Very strange this one - very strange indeed!

Darren

On 20 Mar, 14:46, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
What method are you using to add the cookies to the cookie collection? Are
you using insert? If so then it may simply be appending the added cookie(s)
onto the existing collection. Before, you may check to see if CookieA exists
at some ordinal position by doing something like,
Resposnse.Cookie["CookieA"] = , some cookie

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

<Darren.Ratcli...@gmail.comwrote in message

news:11*********************@n76g2000hsh.googlegro ups.com...
Hi everyone
I'm using v 2.0 of the framework with C# and am developing a web
application.
I am finding that my cookie names are duplicating themselves over and
over again, for example when I write out all the cookie keys and
values, I am getting the following:
CookieA: Apple
CookieB: Banana
CookieC: Carrott
CookieA: Apple
CookieB: Banana
CookieC: Carrott
I don't understand why this is happening - but I feel there may be
some of you out there that know exactly what has caused this
problem... or at least I hope!
Any pointers are most appreciated.
Many thanks
Darren- Hide quoted text -

- Show quoted text -

Mar 21 '07 #4

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

Similar topics

4
by: Brian Burgess | last post by:
Hi all, Anyone know of any special issues with storing cookies with ASP? I'm trying this with two browsers: One is IE 6.0 with cookies set to 'prompt'. This has been working properly as any...
3
by: Raterus | last post by:
Hello, I've got a bunch of web-portals that customers use to log-in and see their data. In a production environment, each of these has a completely different domain name, but they all point back...
1
by: Deepa | last post by:
Hi all I have an asp.net application (Survey form). I have a situation to handle. I have to make sure that the same user doesn't submit the form(click the Save button on the form) more than once...
6
by: Mark | last post by:
Hi... I've come across some weird bug with Response.Cookies. Or maybe it will be called "by design" but for the life of me I can't figure out what purpose it would serve. If you're setting a...
4
by: MJ | last post by:
When I look in relationships I find a couple of tables have duplicated themselves and the titles has an underline and then a number 1 after them. Do you have any idea what would be causing this? ...
4
by: Tom Jones | last post by:
Hi, I place an http request to a web server using HttpWebRequest. When the response comes back (via a HttpWebResponse) the Cookies collection in the response is empty, though if I scan through...
2
by: Samuel R. Neff | last post by:
I'm trying to find a good way to handle Control.InvokeRequired without duplicating four lines of code in every function/event. Typically what I've seen in books is this: If InvokeRequired Then...
0
by: rmli | last post by:
Duplicating a Database using RMAN http://quickdba.blogspot.com/2006/05/duplicating-database-using-rman_22.html
3
by: Peter Michaux | last post by:
Hi, These first three links say that when reading document.cookie the name-value pairs are separated by semicolons and they show examples like "name=value;expires=date" where there is clearly...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.