This is the third place where you've hard-coded the cookie name, so we should probably make it a constant.

Also, I kind of thought the $ was just necessary when you were interacting with jquery; I don't think your local variable names should be prefixed with a $.