Fixed #22426 -- Django >= 1.6.0 can't handle old style messages cookie

Backported the code from 1.5 that adds backwards compatibility with legacy message length. The code that's backported is from commit 9e7183073f64e541587e8dcfd8bb3ddeb47f8162.