Added check for cookies before calling in log_helpers so it does not throw an exception.

In several of our apps imprint is throwing an exception in the log_helpers file due to cookies not being defined. Added a check to make sure cookies is defined before trying to call. Also added printing of some exception information so we are not blind when an exception is rescued.