![]() | |||||
![]() |
|||||
|
ColdFusion Function to set HttpOnly Cookie
It's gotten so I can't think about writing any code without fretting about security while I'm doing it. I know, I know, that's a good thing. Still one does long for the old days when the makers of small to medium-sized websites could get away with lax security just because the big sites had enough security holes to keep the hackers busy. And those hackers didn't have as many automated tools to make hacking lots of sites easier. Anyway, those days are long gone and none of us has to be labeled paranoid, because they really are out to get us. So, on my security checklist was to start using HttpOnly cookies for potentially sensitive cookies (like those related to login). HttpOnly cookies have been supported for a while by Internet Explorer, and Firefox has recently started supporting them. What's good about HttpOnly cookies is that their values can not be accessed through javascript, which stops a variety of cross-site-scripting attacks. For more info, here is a good page: http://www.12robots.com/index.cfm/2009/1/5/mmmmMMmmmmmmm-Cookies--Security-Series-12 The problem that comes up immediately for a ColdFusion developer is that the CFCOOKIE tag does not support httponly cookies. This seems like a gross oversite, especially since it should be very easy to implement. In order to use httponly cookies, you need to use the CFHEADER tag to to write the specially formatted cookie header to the browser. I looked around but couldn't find anyone online that had created a function that handled all of the functions of CFCOOKIE with the addition of httponly. Anyway, here is what I came up with. <cffunction name="SetCookie" hint="Replacement for cfcookie that handles httponly cookies" output="false" returntype="void"> It's actually pretty simple, with the expires portion of the header being the only thing that required a little work. I have attempted to mimic the CFCOOKIE functionality so that this can be used more or less as a simple replacement for that tag. Here's an example of usage: <cfset SetCookie( I hope this proves helpful to others. Posted on October 8, 2009 3:13:19 PM EDT by David Hammond CommentsTopics for this page: |
June 28, 2010 -- Modern Signal launches redeveloped website for National Health Policy Forum, a nonpartisan research and public policy organization at The George Washington University. The new site includes admin tools to manage email announcements, event invitations and RSVPs, surveys, and an extensive library of publications and meeting materials. The site also features a customized Google Search integration, and a new content management system was integrated within the existing design and information architecture of the site. -View-
April 22, 2010 -- Modern Signal launches a redesigned website for The NALP Foundation for Law Career Research and Education, a nonprofit organization that works to ensure that the legal community and society at large have a reliable, objective, and affordable source of information.The site includes a content management system; bookstore; and news, events, leadership, and products tools to manage the featured homepage content. -View-
April 5, 2010 --
|
||||
Posted on February 18, 2010 4:43:15 PM EST by Michael Kane
Posted on February 18, 2010 4:48:22 PM EST by David Hammond