Monday, December 19, 2011

The Bad Taste of ASP Classic Cookies

Recently, Rubicite performed a massive move for a client, transferring a few dozen sites from one server to another. Various things changed about the structure of the site once we moved to the new server, but it went pretty smoothly overall. Today, our client emailed me about an error they were seeing. I obtained a test-worthy login account, and proceeded to try to replicate the error.

And I failed. A simple login did not work. Yet they were able to login with exactly the same credentials I was using. So we start digging through their code, written in classic ASP. After sorting through the web of logic that runs everything, I arrived on a piece of the login system that was tied to writing and reading cookies. Adding debug statements confirmed that the data was there when the cookies were written, and that the data was not being read from the cookies on the other side. So I scanned my system and found that the cookies were indeed present. So I looked further. And read about common problems found in classic ASP cookie processing.

I found that the cookies were created with a path that matched the directory structure they were in on the new webserver. However, when they were retrieved, that directory structure was invisible to the client (as the browser saw the sites as located at the base of their respective subdomain). So the fix became simple: specify the path when the cookies are written. And indeed it was that simple - after making this change and clearing my cookies, everything was back on track and working properly. It's a pretty simple fix too. Just change:
To:

1 comment:

  1. Wow thanks for that! I've been using ASP for about 15 years since it was in BETA as Denali and I've never come across that problem before. :-)

    ReplyDelete