Fixed an issue with migrating legacy json cookies.

Fixes #14774.

*Godfrey Chan*