<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Fourspaces</title>
	<atom:link href="http://blog.fourspaces.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fourspaces.com</link>
	<description>Coding and science from the trenches</description>
	<pubDate>Thu, 18 Sep 2008 18:10:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
		<url>http://www.gravatar.com/blavatar/391d22678e1d8d437fdbc2c98ec362eb?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Fourspaces</title>
		<link>http://blog.fourspaces.com</link>
	</image>
			<item>
		<title>Roche 480 LightCycler can kiss my shiny metal &#8230;..</title>
		<link>http://blog.fourspaces.com/2008/09/18/roche-480-lightcycler-can-kiss-my-shiny-metal/</link>
		<comments>http://blog.fourspaces.com/2008/09/18/roche-480-lightcycler-can-kiss-my-shiny-metal/#comments</comments>
		<pubDate>Thu, 18 Sep 2008 18:10:42 +0000</pubDate>
		<dc:creator>mbreese</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fourspaces.wordpress.com/?p=12</guid>
		<description><![CDATA[It&#8217;s official.  I think the Roche LightCycler 480 has quite possibly the worst user interface in the world&#8230; at least as far as currently available real-time qPCR machines is concerned.
First of all, it reports a Cp value as opposed to a Ct value.  I still have yet to find out what the hell [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>It&#8217;s official.  I think the Roche LightCycler 480 has quite possibly the worst user interface in the world&#8230; at least as far as currently available real-time qPCR machines is concerned.</p>
<p>First of all, it reports a Cp value as opposed to a Ct value.  I still have yet to find out what the hell that means.  I&#8217;m sure that it makes sense, but honestly, why not let the user set their own threshold values?  Or at least give us an option of a couple of calculation methods.</p>
<p>But the biggest problem is that once you start a run, you can&#8217;t stop it.  I spent an hour and a half setting up a plate with samples that will be very hard to get more of.  Instead of using my existing protocol, I mistakenly hit the &#8220;SYBR Green Macro&#8221; that someone had programmed&#8230; expecting it to setup the default experiment and then I&#8217;d be able to adjust things as needed before the run starts.</p>
<p>Yeah&#8230; no.</p>
<p>I put my plate in, and hit the button.</p>
<p>It asked me what to name the experiment, and then proceeded to start running immediately.  No asking.  Just starting.  And the protocol doesn&#8217;t match my primers.  I&#8217;m looking furiously for a stop button.  Oh look, there&#8217;s a bright shiny red X.  I&#8217;ll hit that.  ERROR: &#8220;You can&#8217;t close this screen unless you abort the run&#8221;  Great, I think&#8230; I&#8217;ll just abort the run.  How do I do that?</p>
<p>THERE IS NO WAY TO ABORT THE RUN.</p>
<p>The ABORT button is disabled.  Since the machine takes the plate in with a nifty little sliding tray, you can&#8217;t even manually remove it.</p>
<p>Basically, I&#8217;m screwed and I have the previous two hours of my life to replay.  Thanks Roche.  I&#8217;m sure that your machine gives good data, but you have a ton to learn about how to actually use an instrument in the lab.</p>
<p>Needless to say, I&#8217;m going to lobby heavily against getting a Roche machine ever again.</p>
<p>PS: I&#8217;m stuck using this machine because the Eppendorf realtime machine in my building broke.  That interface was so frickin simple my 7 month old could figure it out.</p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fourspaces.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fourspaces.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fourspaces.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fourspaces.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fourspaces.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fourspaces.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fourspaces.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fourspaces.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fourspaces.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fourspaces.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fourspaces.com&blog=3717917&post=12&subd=fourspaces&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.fourspaces.com/2008/09/18/roche-480-lightcycler-can-kiss-my-shiny-metal/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/30e597f06ca772c014807bbbe03b0d03?s=96&#38;d=identicon" medium="image">
			<media:title type="html">mbreese</media:title>
		</media:content>
	</item>
		<item>
		<title>MobileMe and me</title>
		<link>http://blog.fourspaces.com/2008/08/06/mobileme-and-me/</link>
		<comments>http://blog.fourspaces.com/2008/08/06/mobileme-and-me/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 21:05:00 +0000</pubDate>
		<dc:creator>mbreese</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fourspaces.wordpress.com/?p=10</guid>
		<description><![CDATA[I am one of those sorry souls who bought the original iPhone the day it came out.  I didn&#8217;t have to stand in line, I just happen to live in a city that had shorter lines and a ton of inventory left just before the stores closed at 10pm.
The lure of push-email was enough [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am one of those sorry souls who bought the original iPhone the day it came out.  I didn&#8217;t have to stand in line, I just happen to live in a city that had shorter lines and a ton of inventory left just before the stores closed at 10pm.</p>
<p>The lure of push-email was enough to get me to upgrade my phone to the 2.0 firmware (that and super monkey ball, which ironically I never bought).  The only problem is that my email habits have been pretty firm over the past 4 years in the form of Gmail.  I have multiple email accounts end up in my Gmail inbox.  All roads lead to Gmail, as it were.  I have really gotten used to the Gmail view of mail&#8230; don&#8217;t delete anything, just archive and search.  I don&#8217;t really use labels too much, except for filtering out mailing lists.  The only feature that I use consistently was using multiple &#8216;From&#8217; email addresses.  I love being able to instantly switch what email account I&#8217;m sending mail from: gmail.com, my personal email account, or my work account.  It makes life simple.</p>
<p>Except Gmail and IMAP don&#8217;t quite work the same way.  When you delete a message with Gmail&#8217;s IMAP server, you do Archive the message online, but not the conversation, so it&#8217;s not a true sync.  Also, Gmail&#8217;s IMAP can be pretty slow&#8230; very slow&#8230;  And like a lot of people, I want push email.</p>
<p>Now, since I have a Mac and all that entails, I was not about to subject myself to the hell that is Entourage and Exchange.  (If I was running Windows, I&#8217;d be all over an Exchange account and this post would never have happened).  So, that means I&#8217;m trying out MobileMe.  But since I want the ability to back out of this and go back to Gmail, the configuration is a bit different.</p>
<p>So far here&#8217;s my setup:<br />
I have my work and personal email accounts forward to both Gmail and MobileMe.  I then have Gmail forward things sent directly to Gmail to MobileMe.   So now I get push email of all my accounts.  But what about the two features that I use most: Archiving and Multiple email address sending?  Turns out this is a bit harder.</p>
<p>Multiple email address sending is a bit easier to explain.  On my Mac, in Mail, I have only my MobileMe account setup.  It is set to use the Gmail SMTP servers as opposed to the MobileMe ones.  Since MobileMe is just a fancy IMAP server, all send mail goes into the &#8220;Sent Messages&#8221; folder anyway, and this way Gmail still indexes the messages.  Gmail is setup to accept (for sending) mail from my personal, work, and MobileMe accounts, so that is all the same.  To get the Mac&#8217;s Mail app to support this, all you have to do is add each email address you support in the &#8220;Email Address&#8221; field in the Account setup screen (comma delimited).</p>
<p>On the iPhone it&#8217;s a bit more tricky.  To get this to work, you need to setup email accounts for each address you&#8217;d like to use.  And they have to be &#8220;Active&#8221;.  But you don&#8217;t want to check all of those accounts.  So once you have it all setup, you can then remove the information about the Incoming servers.  This effectively makes the accounts send-only.  I&#8217;ve gone ahead and made sure that the accounts use Gmail&#8217;s SMTP servers again, so Google can index things for me.  The only downside is that I&#8217;ve lost the ability to access the sent message from my desktop machine&#8217;s Mail app, but I could access it from Gmail&#8217;s IMAP interface, if I really needed to.</p>
<p>Archiving things is a bit more tricky, and I&#8217;ll describe that (and my script that facilitates it - yes, it needs a little help) in a later post.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fourspaces.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fourspaces.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fourspaces.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fourspaces.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fourspaces.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fourspaces.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fourspaces.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fourspaces.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fourspaces.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fourspaces.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fourspaces.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fourspaces.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fourspaces.com&blog=3717917&post=10&subd=fourspaces&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.fourspaces.com/2008/08/06/mobileme-and-me/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/30e597f06ca772c014807bbbe03b0d03?s=96&#38;d=identicon" medium="image">
			<media:title type="html">mbreese</media:title>
		</media:content>
	</item>
		<item>
		<title>Python + MySQL + Mac = @#&#38;^%#$!$# (frustration)</title>
		<link>http://blog.fourspaces.com/2008/07/16/python-mysql-mac-frustration/</link>
		<comments>http://blog.fourspaces.com/2008/07/16/python-mysql-mac-frustration/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 20:40:44 +0000</pubDate>
		<dc:creator>mbreese</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fourspaces.wordpress.com/?p=8</guid>
		<description><![CDATA[So I have this nice shiny MacBook pro that I&#8217;d like to start doing my programming on.  Prior to this I was using a combination of a Linux server and a Windows laptop for development work.  All of my prior development on my (older) Mac was in Java.  My new machine is a Core 2 [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So I have this nice shiny MacBook pro that I&#8217;d like to start doing my programming on.  Prior to this I was using a combination of a Linux server and a Windows laptop for development work.  All of my prior development on my (older) Mac was in Java.  My new machine is a Core 2 Duo MacBook Pro running Leopard (this become important).</p>
<p>Java is nice&#8230; libraries are all .jar files that are so platform independent you rarely have to worry about Mac/Linux/Windows issues (for the most part).  However, I&#8217;ve been trying to expand my programming languages by adding Python to the list.  I&#8217;ve been working with Python a decent amount recently and found it to be quite pleasant.</p>
<p>So when it came time to start a new set of data analysis, I thought, ehh, I&#8217;ll just do it in Python.</p>
<p>And that was my mistake.</p>
<p>I got MySQL installed pretty easily by downloading the x86_64 Mac binary from mysql.com.  This went off without a hitch.</p>
<p>Next I tried to install MySQL-Python.  First I tried easy_install, and that failed with:<br />
<code><br />
In file included from /usr/local/mysql/include/mysql.h:47,<br />
                from _mysql.c:40:<br />
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’<br />
/usr/include/sys/types.h:92: error: two or more data types in declaration specifiers</code></p>
<p>error: Setup script exited with error: command &#8216;gcc&#8217; failed with exit status 1<br />
</code></p>
<p>That doesn&#8217;t look good.  Lo and behold, there is a bug in the python-mysql library.  But wait, isn&#8217;t python platform independent?  Well&#8230; kinda.  As it turns out Python is the funky hybrid system where some of the libraries can be compiled C and others pure Python.  From the Java perspective, it&#8217;s similar to having some JNI native code mixed in&#8230; only this particular library doesn&#8217;t do it very well (on a Mac).</p>
<p>But, I&#8217;m a smart guy&#8230; I used to be a C guy in a former life, and I know how to use Google.  Turns out, it&#8217;s a <a href="http://www.keningle.com/?p=11">very simple fix</a>.  A few commented out lines, and  a s/uint/unsigned integer/g later and I&#8217;m in business.  I run:<br />
<code><br />
python setup.py build<br />
python setup.py install <br />
</code><br />
and hope for the best&#8230; but I&#8217;d be wrong.  If you try to import MySQLdb in python, you get this error:<br />
<code><br />
Traceback (most recent call last):<br />
  File &#8220;&lt;stdin&gt;&#8221;, line 1, in &lt;module&gt;<br />
  File &#8220;build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py&#8221;, line 19, in &lt;module&gt;<br />
  File &#8220;build/bdist.macosx-10.5-i386/egg/_mysql.py&#8221;, line 7, in &lt;module&gt;<br />
  File &#8220;build/bdist.macosx-10.5-i386/egg/_mysql.py&#8221;, line 6, in __bootstrap__</code></p>
<p>ImportError: dynamic module does not define init function (init_mysql)<br />
</code></p>
<div>which means absolutely nothing to me.  Turns out, I&#8217;m <a href="http://forums.mysql.com/read.php?50,175059,187685">not the only one</a>.</div>
<div>Here&#8217;s the issue.  If you look a little closer to the gcc output when building mysql-python, you see this gem at the bottom:</div>
<p><code>gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/_mysql.o -Os -arch x86_64 -fno-common</p>
<p>gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch i386 -arch ppc build/temp.macosx-10.5-i386-2.5/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -o build/lib.macosx-10.5-i386-2.5/_mysql.so</p>
<p>ld warning: in build/temp.macosx-10.5-i386-2.5/_mysql.o, file is not of required architecture<br />
ld warning: in /usrld warning: in build/temp.macosx-10.5-i386-/local/mysql2.5/_mysql.o,/lib/libmysqlclient_r.dylib, file is not of required architecture<br />
file is not of required architecture<br />
ld warning: in /usr/local/mysql/lib/libmysqlclient_r.dylib, file is not of required architecture<br />
</code></p>
<div>Did you catch that?  I&#8217;ll give you a clue&#8230; check out the -arch flags.  Remember, I&#8217;m running x86_64 MySQL.  Bingo! the .so file is built as i386 and ppc.  The .o file is correctly built as x86_64, but the next step fails.  So maybe if we just add an -arch x86_64 to the second gcc command, we should be in business, right? (I removed -arch ppc and -arch i386 in both gcc lines, and re-ran them)</div>
<div>Right?</div>
<p><code><br />
$ gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -Dversion_info=&#8221;(1,2,2,&#8217;final&#8217;,0)&#8221; -D__version__=1.2.2 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/_mysql.o -Os -arch x86_64 -fno-commonin</p>
<p>$ gcc -Wl,-F. -bundle -undefined dynamic_lookup -arch x86_64 build/temp.macosx-10.5-i386-2.5/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -o build/lib.macosx-10.5-i386-2.5/_mysql.so</p>
<p>$ python setup.py install<br />
</code></p>
<div>Finally, no compiler errors!  No linker errors! Now to try to import MySQLdb from python again&#8230;&#8221;</div>
<div>and FAIL</div>
<p><code><br />
Traceback (most recent call last):<br />
File &#8220;&#8221;, line 1, in<br />
File &#8220;build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py&#8221;, line 19, in<br />
File &#8220;build/bdist.macosx-10.5-i386/egg/_mysql.py&#8221;, line 7, in<br />
File &#8220;build/bdist.macosx-10.5-i386/egg/_mysql.py&#8221;, line 6, in __bootstrap__<br />
ImportError: dlopen(/Users/mbreese/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:<br />
/Users/mbreese/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so: mach-o, but wrong architecture<br />
</code></p>
<div>What on earth am I doing wrong?  I removed the i386 from the .egg file, and checked that too.  Still no joy.  If I look at that file, I see that it is x86_64</div>
<p><code><br />
$ file /Users/mbreese/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5.egg-tmp/_mysql.so<br />
/Users/mbreese/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.5.egg-tmp/_mysql.so: Mach-O 64-bit bundle x86_64<br />
</code></p>
<div>Hmm&#8230; what about python itself?  Now, this is stock Python 2.5 from Apple.</div>
<p><code><br />
$ file `which python`<br />
/usr/bin/python: Mach-O universal binary with 2 architectures<br />
/usr/bin/python (for architecture ppc7400):	Mach-O executable ppc<br />
/usr/bin/python (for architecture i386):	Mach-O executable i386<br />
</code></p>
<div>My current theory is that since Python is 32-bit only it can only link to 32 bit only libraries (makes sense).  However, MySQL is installed as 64-bit only and only has 64 bit libraries (also makes sense).  So never the two shall mix&#8230; it&#8217;s like oil and water. </p>
<p>I&#8217;m going to try to see if a 32-bit install of MySQL will work, but that pretty much seems like a shame to have to roll back to 32 bit MySQL just to satisfy Python.  Perhaps it would have been easier to just stick to Java.</p></div>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fourspaces.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fourspaces.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fourspaces.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fourspaces.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fourspaces.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fourspaces.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fourspaces.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fourspaces.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fourspaces.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fourspaces.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fourspaces.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fourspaces.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fourspaces.com&blog=3717917&post=8&subd=fourspaces&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.fourspaces.com/2008/07/16/python-mysql-mac-frustration/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/30e597f06ca772c014807bbbe03b0d03?s=96&#38;d=identicon" medium="image">
			<media:title type="html">mbreese</media:title>
		</media:content>
	</item>
		<item>
		<title>Bullet-proof cookies?  Why bother?</title>
		<link>http://blog.fourspaces.com/2008/05/14/bullet-proof-cookies-why-bother/</link>
		<comments>http://blog.fourspaces.com/2008/05/14/bullet-proof-cookies-why-bother/#comments</comments>
		<pubDate>Wed, 14 May 2008 18:54:30 +0000</pubDate>
		<dc:creator>mbreese</dc:creator>
		
		<category><![CDATA[coding]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://fourspaces.wordpress.com/?p=6</guid>
		<description><![CDATA[This post was on the front-page of Dzone today: Bullet Proof Cookies.  It got like 7 up votes when I saw it.  Did anyone actually read the article?  This shows a horrible way to use cookies.  Well, maybe not horrible, but at least it is certainly over-kill.
The author recommends encrypting your cookie data, [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This post was on the front-page of Dzone today: <a href="http://www.dzone.com/links/bullet_proof_cookies.html">Bullet Proof Cookies</a>.  It got like 7 up votes when I saw it.  Did anyone actually read the article?  This shows a horrible way to use cookies.  Well, maybe not horrible, but at least it is certainly over-kill.</p>
<p>The author recommends encrypting your cookie data, digitally signing it, and sending that to the browser.  The idea is that by encrypting the data, the client won&#8217;t be able to know what it is or modify it. This is a nice way to go, but why go through the trouble when you don&#8217;t need to store data in cookies to begin with?</p>
<p>Specifically, my rule of thumb is that if you don&#8217;t want a client to know the data, <strong>don&#8217;t send it to them</strong>.</p>
<p>The most common feature to use cookies to store information is the &#8220;remember-me&#8221; feature of most web sites.  Once a user successfully logs in, you want to allow them to be auto-logged in.  The author of the above article suggests that you send them their userid, but since you don&#8217;t want them modifying the cookie, you encrypt it.  Well, that&#8217;s one way to do it (the hard way).</p>
<p>There are two other methods that are easier (and still secure):</p>
<ul>
<li>Send hashed data</li>
<li>Send a randomly generated ID that links to data on the server</li>
</ul>
<p><strong>Secure</strong></p>
<p>I&#8217;ve not looked at the internals of WordPress, but based upon the cookies that I have on my system from wordpress.com, it looks like they implement the remember-me function by sending a string that looks like something this: username%hexadecimalsalt%hex-sha1?-salted-hashed-password. (I could be wrong about what WordPress does, but since this is how *nix /etc/passwd files work, it&#8217;s pretty secure anyway)</p>
<p>In this case, you don&#8217;t see the password, but you have the hash of the password.  If you change the username, it won&#8217;t work.  If you change the rest of the string, it won&#8217;t work.  The only downside, is that if an attacker has enough time, they _could_ figure out what your password is using a brute-force approach.  This technique is useful in situations where you are checking two values, and unsecured one, and a secured one (the username and the password).  On the server side, you can use the browser&#8217;s cookie value to lookup the username, and compare the sent hash with a calculated one.  But what should you do if you don&#8217;t have a unsecured data to perform a lookup?  The answer is: use a randomly generated id.</p>
<p><strong>More secure</strong></p>
<p>I personally never store data in a cookie, but rather store a randomly generated identifier that maps to the data on the server-side. This is very similar to the way that sessions are implemented (PHP,Java, ASPX,etc).  Let&#8217;s say you have a user that wants to be auto-logged in (remembered) with they visit your site the next time.  What I do is to add a new field to my database&#8217;s user table named &#8220;rememberme&#8221;.  Then I&#8217;ll generate a new, random string (UUID, SHA1 hash of some random value, etc&#8230;).  I&#8217;ll then store that value in the database user user.rememberme, and send that value to the user as a cookie.  This avoids storing data on the browser that could be exploited, and lets the user still have their remember-me functionality.</p>
<p><strong>A bit more secure<br />
</strong></p>
<p>Now, this approach is no more or less secure than standard cookie based sessions.  That is to say, it can be easily hijacked if someone obtains the value of the cookie.  One way to generate some sort of signature of the user&#8217;s browser using the User-agent, IP address, etc&#8230;  This could be as simple as using only the IP address, or concatenating the User-agent string, IP address, the &#8220;Accept-*&#8221; headers, etc, and hashing the concatenated string.  You could then store this browser signature along with the randomly generated id above.  This would give you a little more data to use to authenticate your user and be more confident that it isn&#8217;t a man in the middle attack.</p>
<p><strong>Paranoid level of security</strong></p>
<p>Now, if you must store data in a cookie that the user isn&#8217;t supposed to know, or that you don&#8217;t want to store in plaintext (passwords), then yes, encrypting and signing the data will make it more secure.  But you&#8217;ll be adding a ton of overhead to your HTTP request, so be sure to restrict the domain of the cookie.  Also you&#8217;ll still not be able to verify that the client is who you think they are.  To do this, you&#8217;ll need to combine one of the above methods with <a href="http://cookies.lcs.mit.edu/sslflag.html">SSL-only cookies</a> and the secure bit.  And if you&#8217;re need this level of security, you probably shouldn&#8217;t be using HTTP anyway, you should be using HTTPS.  (Actually, if you need this level of security, you already know all of this and shouldn&#8217;t be reading this!).</p>
<p>I hope this helps, and gives you a few more tools to use in your secure cookie arsenal without needing full-blown encryption.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fourspaces.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fourspaces.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fourspaces.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fourspaces.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fourspaces.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fourspaces.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fourspaces.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fourspaces.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fourspaces.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fourspaces.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fourspaces.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fourspaces.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fourspaces.com&blog=3717917&post=6&subd=fourspaces&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.fourspaces.com/2008/05/14/bullet-proof-cookies-why-bother/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/30e597f06ca772c014807bbbe03b0d03?s=96&#38;d=identicon" medium="image">
			<media:title type="html">mbreese</media:title>
		</media:content>
	</item>
		<item>
		<title>Moving to WordPress&#8230;</title>
		<link>http://blog.fourspaces.com/2008/05/13/moving-to-wordpress/</link>
		<comments>http://blog.fourspaces.com/2008/05/13/moving-to-wordpress/#comments</comments>
		<pubDate>Tue, 13 May 2008 18:21:52 +0000</pubDate>
		<dc:creator>mbreese</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://fourspaces.wordpress.com/?p=3</guid>
		<description><![CDATA[Well, I know that this has the effect of breaking links&#8230; and this sucks.  So, I&#8217;m leaving up the old site at: fourspaces.com/blog for a while until I can figure out what I&#8217;m going to do to make sure that existing links redirect.  This is mainly to protect the links to the FeatherDB [...]]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Well, I know that this has the effect of breaking links&#8230; and this sucks.  So, I&#8217;m leaving up the old site at: fourspaces.com/blog for a while until I can figure out what I&#8217;m going to do to make sure that existing links redirect.  This is mainly to protect the links to the FeatherDB information.  Perhaps I&#8217;ll split that out as a main project in the future (Embeddable Document DB for Java?)  Maybe we&#8217;ll rename it &#8220;Eddy&#8221; :)</p>
<p>Perhaps now I&#8217;ll start writing more often about what is happening.  This was also precipitated by the lack of spam-fighting ability in my custom written blog engine that I was running.  I&#8217;m also starting to get tired of using Java for web-apps in general, so I feel less of a need to dogfood my own frameworks.</p>
<p>So, we&#8217;ll see how it goes.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/fourspaces.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/fourspaces.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/fourspaces.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/fourspaces.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/fourspaces.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/fourspaces.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/fourspaces.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/fourspaces.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/fourspaces.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/fourspaces.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/fourspaces.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/fourspaces.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.fourspaces.com&blog=3717917&post=3&subd=fourspaces&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://blog.fourspaces.com/2008/05/13/moving-to-wordpress/feed/</wfw:commentRss>
	
		<media:content url="http://www.gravatar.com/avatar/30e597f06ca772c014807bbbe03b0d03?s=96&#38;d=identicon" medium="image">
			<media:title type="html">mbreese</media:title>
		</media:content>
	</item>
	</channel>
</rss>