IE Forgets Cookies on Sub-Domains with an Underscore

Internet Explorer Fail LogoOk, so one more reason to hate IE: Internet Explorer fails to hold cookies when viewing URLs that have a sub-domain with an underscore. I found this when the project I'm developing just refused to hold on to a session when viewing the site from Internet Explorer. Almost all of the server-side technology I was using was new to me, so I lost a full day trying to figure out if it was ColdFusion 9, IIS7, or the ColdFusion on Wheels framework that was breaking the sessions before I found out that the IE browsers choke on underscores. FireFox and Chrome didn't care about the underscore, but IE6 through IE8 lost their session because they couldn't hold onto the cookies for the site.

So, if you're loosing your sessions in Internet Explorer, check your URL. I'm not sure if there are other characters besides an underscore that would cause the cookie loss, but it wouldn't surprise me.

 

Installing ColdFusion on IIS7 Still a Pain

Vista iconThis post isn't anything new, but I felt that I should document that yet another person has wasted some of their life struggling to get CF working on an IIS7 machine. I first ran into this problem about 6 months ago when trying to install CF8 on Windows Server 2008 (64-bit), and we had so many problems doing it that the server was rolled back to Windows Server 2003 (32-bit) to get around it. Today I had to get CF9 installed on a Vista, and had to deal with the same issues all over again. Luckily the solution was simpler this time, and involved only one reinstall of CF, rather than 5 and a full wipe of an OS like last time.

Why hasn't this been fixed by now?

Oh, and for those needing a solution, I found mine at Dale Fraser's Blog.

 

[Macromedia][SQLServer JDBC Driver]Object has been closed.

I got this error for the first time today, while trying to get a query working in ColdFusion 8.01. I'd defined some custom functions in SQL Server, and tested them out through the SQL Server Management Studio, but the datasource user didn't have the right permissions to use the queries. I added the permissions, reloaded the page and got smacked with the following error:

[Macromedia][SQLServer JDBC Driver]Object has been closed.

I found the solution on House of Fusion: restart your ColdFusion services. Something about the lack of permissions seems to catch in CF, and wont be released until you restart.

 

IIS vs onMissingTemplate

Several weeks back I was exposed to Python and Django for the first time, and it really got me thinking. While I'm not a huge fan of Python syntax, I really did like the setup for Django, and how it implements MVC. One of the first things that I loved was this little tid-bit for linking up URL requests to views:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P<poll_id>\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
)

In that block, Django is defining regular expressions that map to Python functions, and defining how to pull named variables out of that regular expression, so that if you requested /polls/23/ becomes a call to the mysite.polls.views module to do the following:

# mysite.polls.views is the module, details is the function
detail(request=<HttpRequest object>, poll_id='23')

Isn't that cool? I'd love to be able to do that in ColdFusion, but it looks like there are a number of hurtles I have to get past before I can make this work:

  1. How do I make ColdFusion get the variables out of that URL path?
  2. How do I make ColdFusion look at a URL that doesn't exist?

 

IsDate() and SQL Server

I don't know about you, but my company uses the IsDate() function for a lot of simple validation of date inputs, and it works fairly well for the most part. The only problem I have with it is that when paired with SQL Server (2000 or 2005), it still can't capture all invalid dates.

The date 'January 5, 753' is a valid date, but attempting to insert it into a SQL Server datetime object throws an error because valid dates for SQL Server are between January 1, 1753 and December 31, 9999. Dates above the year 9999 are caught by IsDate(), but the lower bound is not.


<cffunction name="IsSQLServerDate" returntype="boolean" output="false">
    <cfargument name="date" type="date" required="true"/>
    <cfargument name="type" type="string" required="false" default="datetime"/>

    <cfswitch expression="#arguments.type#">
        <cfcase value="datetime">
            <cfreturn IsDate(arguments.date) AND Year(arguments.date) gte 1753 />
        </cfcase>
        <cfcase value="smalldatetime">
            <cfreturn IsDate(arguments.date) AND DateCompare(arguments.date, '1/1/1900') gte 0 AND DateCompare(arguments.date, '6/2/2079') lte 0 />
        </cfcase>
    </cfswitch>
</cffunction>

Nothing that someone else couldn't write, but useful. to save headaches.

 

Recursive CTE in SQL Server 2005

Recursive Common Table Expressions are solving a lot of problems for me at work today, so I thought I'd throw a note up on here about them. Its a common problem with databases that records often have a parent record in the same table, which can in turn have another parent and so forth up the chain. What happens is that at some point you need to find out the whole structure of the tree, which becomes much more difficult. Enter RCTE. While I've known that other servers had capabilities like this for a while (Oracle for example), I'd not seen a good way to do it in SQL Server.

Find out a little more at the bottom of this page.

And an official Microsoft page can be found here.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.