Aargh!! Cookie paths are case-sensitive!! How do you cope with THAT?

  • Thread starter Thread starter Alan Silver
  • Start date Start date
A

Alan Silver

Hello,

I've just spent ages debugging some cookie code that wasn't working, and
have finally discovered that the code *was* working, but that the path
used by cookies is case-sensitive. I was setting a cookie for a path
like "/somepath", and trying to read it on a path like "/SomePath". This
was coming back as a non-set cookie.

So now I know what the problem is, I'm stuck with how to get around it.
In an ideal world, users would only ever click on links, not enter URLs
themselves, external sites wouldn't change the case of your URLs and so
on. Unfortunately, this isn't the case.

So, if a user enters http://domain/MyUrl/ and the cookie was set for
"/myurl", can I read it?
 
you could read the folder name and then use that value to set the cookie.

The problem is reading the cookie, setting it is easy as I can just use
..ToLower() to make sure the cookie path is lowercase. If the URL in the
user's browser contains any uppercase letters, then I won't be able to
read the cookie. Short of redirecting to a lowercase version of the URL
(which has many side issues that I'd rather not handle), I can't see how
I can READ the cookie.

Thanks for the reply. Any further comments welcome.
 
if you read the folder name and assign it to a variable i believe it will retain the case. us ehte varible as part of the cookie
path and it should be the same , eh ?



=========================================
And preachers also once said the world was flat ....
 
if you read the folder name and assign it to a variable i believe it
will retain the case. us ehte varible as part of the cookie
path and it should be the same , eh ?

That still doesn't address the problem. Let me explain a little more..

Suppose a page sets a cookie for the path /somepath/ on the server.

Later on, the user comes back to the web site, but for some reason (of
which there are many), he access it via the URL
http://www.domain.com/SomePath/. The path /somepath/ does not match
/SomePath/, so the cookie is not read.

Sure I can read the current path, including the case of each letter, but
I need to know the case of the original path.
 
In this scenario, you'll have to create a comparison loop.

Get all the folders and compare them to the user's request in the same case . If a match is found, then use assign actual folder
name to a variable and use it, else, report no match found.

============================================================
"The highest courage is to dare to be yourself in the face of adversity.
Choosing right over wrong, ethics over convenience, and truth over
popularity.. These are the choices that measure your life. Travel the path
of integrity without looking back, for there is never a wrong time to do the
right thing."
 
Back
Top