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

using _ in cookie names

I have an existing site that's being update from ASP to ASP.NET (C#).
The site uses cookies and I've having trouble reading them.

For example, one Cookie created using ASP was "member_id", and using
ASP I simply get the value using 'request.cookies("member_id")'

However, using C# I have to replace '_' with '%5F' or it won't get
read, i.e.

string tempVar = Request.Cookies["member%5Fid"]

is this expected, or is there a way to locate the cookie more easily,
i.e. with the underscore character?

tia

May 30 '06 #1
7 2921
Kevin,
not to sound blunt but, why not just avoid using problematic cookie names in
the first place?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Blount" wrote:
I have an existing site that's being update from ASP to ASP.NET (C#).
The site uses cookies and I've having trouble reading them.

For example, one Cookie created using ASP was "member_id", and using
ASP I simply get the value using 'request.cookies("member_id")'

However, using C# I have to replace '_' with '%5F' or it won't get
read, i.e.

string tempVar = Request.Cookies["member%5Fid"]

is this expected, or is there a way to locate the cookie more easily,
i.e. with the underscore character?

tia

May 30 '06 #2
Can you use [@"member_id"] ???

Sa
"Kevin Blount" <ke**********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
I have an existing site that's being update from ASP to ASP.NET (C#).
The site uses cookies and I've having trouble reading them.

For example, one Cookie created using ASP was "member_id", and using
ASP I simply get the value using 'request.cookies("member_id")'

However, using C# I have to replace '_' with '%5F' or it won't get
read, i.e.

string tempVar = Request.Cookies["member%5Fid"]

is this expected, or is there a way to locate the cookie more easily,
i.e. with the underscore character?

tia

May 31 '06 #3
As previously stated, this is an existing site that's being updated, so
I have to use and cater for cookies created by that existing site.
Obviously I can't go to all previous visitors to our site and
rename/update their cookies, so I have to use existing cookies with _
char in them..

now that we're over that.. any ideas?

Peter wrote:
Kevin,
not to sound blunt but, why not just avoid using problematic cookie names in
the first place?
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Kevin Blount" wrote:
I have an existing site that's being update from ASP to ASP.NET (C#).
The site uses cookies and I've having trouble reading them.

For example, one Cookie created using ASP was "member_id", and using
ASP I simply get the value using 'request.cookies("member_id")'

However, using C# I have to replace '_' with '%5F' or it won't get
read, i.e.

string tempVar = Request.Cookies["member%5Fid"]

is this expected, or is there a way to locate the cookie more easily,
i.e. with the underscore character?

tia


May 31 '06 #4
Good call, but unfortunately that didn't work. Thanks for the idea
though

msdn wrote:
Can you use [@"member_id"] ???

Sa
"Kevin Blount" <ke**********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
I have an existing site that's being update from ASP to ASP.NET (C#).
The site uses cookies and I've having trouble reading them.

For example, one Cookie created using ASP was "member_id", and using
ASP I simply get the value using 'request.cookies("member_id")'

However, using C# I have to replace '_' with '%5F' or it won't get
read, i.e.

string tempVar = Request.Cookies["member%5Fid"]

is this expected, or is there a way to locate the cookie more easily,
i.e. with the underscore character?

tia


May 31 '06 #5
"Kevin Blount" <ke**********@gmail.com> writes:
string tempVar = Request.Cookies["member%5Fid"]


I suppose that the Cookie-names are not URL-decoded.

You could write it a little bit more readable by using
string tempVar = Rquest.Cookies[Server.UrlEncode("member_id")];

Best regards,
Martin
Jun 1 '06 #6
Martin Carpella wrote:
string tempVar = Rquest.Cookies[Server.UrlEncode("member_id")];


Unfortunately that didn't work either, Martin, but it's around where I
was looking. I just tried using Server.HtmlEncode as well, but neither
return the value of the that cookie.

Oh well..going forward I will be using .NET friendly names, but I'll
have to have to stick with %2f for existing ones.

Thanks for trying all.

Jun 2 '06 #7
"Kevin Blount" <ke**********@gmail.com> writes:
Martin Carpella wrote:
string tempVar = Rquest.Cookies[Server.UrlEncode("member_id")];


Unfortunately that didn't work either, Martin, but it's around where I
was looking. I just tried using Server.HtmlEncode as well, but neither
return the value of the that cookie.


Oh, I see, Server.UrlEncode seems to return lower-case characters, while
you are needing upper case... Sorry, missed that one.

Best regards,
Martin
Jun 5 '06 #8

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

Similar topics

3
by: Ralph Freshour | last post by:
I wrote a small .php script that creates a cookie on my local PC - I also wrote one that deletes it. My question is this: when the cookie has been created and I run the delete .php script, when...
16
by: Phil Powell | last post by:
Fourth attempt.. it fails now in login, I check by printing $_COOKIE and there is no value there! Guys, what on earth do I do about this???? Here is the code that sets the cookie: if...
0
by: s_m_b | last post by:
Having just migrated to w2k from NT4, I've stumbled across an oddity with cookie handling - at least, that's what it appears to be. I (was) using response.buffer with .addheader to write two...
14
by: Alec S. | last post by:
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. ...
1
by: Daniel Michaeloff | last post by:
Hi all, I have an application that when finished redirects to a non-ASP.NET app which is choking on a huge ASP.NET session cookie. The cookie "ASP.NET_SessionId" gets transmitted by the browser...
1
by: Lu Wei | last post by:
Hello, I'm writing a script to send posts to a web forum. I find that MSXML2.XMLHTTP object could communicate with web server but I can't make it send cookie which is needed for post...
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...
2
by: zensunni | last post by:
I'd like to assign an array to a cookie. But, I can't incrementally assign cookie names, thus, I can't assign different values. Here is the code that should work, but doesn't let me. count = 0...
5
by: Rajkiran R.B. | last post by:
I want to log in to a website using C# code.. The main aim is to check whether the username and password I provide is correct or not. I used the following code bool somefunction() {...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.