Home All Groups Group Topic Archive Search About

Writing cookies from ASP with spaces and hyphens



Author
6 Mar 2005 3:16 PM
Robin Briggs
Hi.

I have an ASP (3.0, not .NET) app that writes cookies with hyphens and
spaces in the names and values. If I had the control over the apps that will
be looking for these cookies, I would eliminate the special characters, but
as it is, I do not have that luxury.

When I write the cookies, they seem okay in IE, but in Firefox, they are
strange. For example, the cookie name is US-NONUS, but in Firefox it looks
like US%2DNONUS. For a value of NEW HAMPSHIRE it comes out in Firefox as
NEW+HAMPSHIRE.

Please note that these strings are not created in any special way: They are
hard-coded into the ASP, with no encoding or anything like that.

Thoughts?

Thanks.

Author
6 Mar 2005 4:30 PM
Evertjan.
Robin Briggs wrote on 06 mrt 2005 in
microsoft.public.inetserver.asp.general:

> When I write the cookies, they seem okay in IE, but in Firefox, they
> are strange. For example, the cookie name is US-NONUS, but in Firefox
> it looks like US%2DNONUS. For a value of NEW HAMPSHIRE it comes out in
> Firefox as NEW+HAMPSHIRE.

That would be nice new way of browswer detection, btw!

However, testing this in both Firefosx and IE shows it is not true:

======= test.asp =============

<%=request.cookies("test")%>

<%
response.cookies("test")="New Hampshire-Test"
%>

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

Perhaps your <form method=..> is the culprit???

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
6 Mar 2005 6:56 PM
Robin Briggs
I think we are miscommunicating. I am talking about WRITING cookies. Has
nothing to do with reading them. Has nothing to do with the form submit.
Somewhere in the middle of several hundred lines of ASP code, I write
cookies that, when viewed in Firefox, show up with characters I did not use.

If you have any ideas, that would be appreciated.

Show quote
"Evertjan." <exjxw.hannivo***@interxnl.net> wrote in message
news:Xns9611B2142DFDEeejj99@194.109.133.29...
> Robin Briggs wrote on 06 mrt 2005 in
> microsoft.public.inetserver.asp.general:
>
>> When I write the cookies, they seem okay in IE, but in Firefox, they
>> are strange. For example, the cookie name is US-NONUS, but in Firefox
>> it looks like US%2DNONUS. For a value of NEW HAMPSHIRE it comes out in
>> Firefox as NEW+HAMPSHIRE.
>
> That would be nice new way of browswer detection, btw!
>
> However, testing this in both Firefosx and IE shows it is not true:
>
> ======= test.asp =============
>
> <%=request.cookies("test")%>
>
> <%
> response.cookies("test")="New Hampshire-Test"
> %>
>
> ====================
>
> Perhaps your <form method=..> is the culprit???
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>
Author
6 Mar 2005 7:46 PM
Evertjan.
Robin Briggs wrote on 06 mrt 2005 in
Show quote
> "Evertjan." <exjxw.hannivo***@interxnl.net> wrote in message
>> Robin Briggs wrote on 06 mrt 2005 in
>>
>>> When I write the cookies, they seem okay in IE, but in Firefox, they
>>> are strange. For example, the cookie name is US-NONUS, but in
>>> Firefox it looks like US%2DNONUS. For a value of NEW HAMPSHIRE it
>>> comes out in Firefox as NEW+HAMPSHIRE.
>>
>> That would be nice new way of browswer detection, btw!
>>
>> However, testing this in both Firefosx and IE shows it is not true:
>>
>> ======= test.asp =============
>>
>> <%=request.cookies("test")%>
>>
>> <%
>> response.cookies("test")="New Hampshire-Test"
>> %>
>>
>> ====================
>>
>> Perhaps your <form method=..> is the culprit???

> I think we are miscommunicating. I am talking about WRITING cookies.
> Has nothing to do with reading them. Has nothing to do with the form
> submit. Somewhere in the middle of several hundred lines of ASP code,
> I write cookies that, when viewed in Firefox, show up with characters
> I did not use.
>
> If you have any ideas, that would be appreciated.
>

[Please do not toppost. Topposting corrected]

Robin,

No miscommunication from this side, me thinks.

My test.asp above writes a cookie every time you press F5, and before it
writes the cookie, it reads the cookie that is written last F5 press.

The read cookie shows up as written in both browsers.

Of course you will have to read them in a test situation to see the
result.

[The <form > was just a suggestion as a probable source of the error]

Did you try to reproduce the error with my code? And what was the result?

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Author
9 Mar 2005 5:30 PM
Ben Strackany
"Robin Briggs" <rbri***@emedicine.com> wrote in message
news:ORbWs4nIFHA.3500@TK2MSFTNGP14.phx.gbl...
> I think we are miscommunicating. I am talking about WRITING cookies. Has
> nothing to do with reading them. Has nothing to do with the form submit.
> Somewhere in the middle of several hundred lines of ASP code, I write
> cookies that, when viewed in Firefox, show up with characters I did not
use.

"When viewed in firefox" you mean via the cookie browser? If so, that
shouldn't matter -- firefox can store the cookies however it wants to. Some
browsers are going to encode the values. All you should worry about is that
your code, when reading the cookie value, gets the unencoded value (e.g.
"US-NONUS" instead of "US%2DNONUS") .

--
Ben Strackany
www.developmentnow.com

AddThis Social Bookmark Button