Fixed an issue with migrating legacy json cookies.

Fixes #14774.

*Godfrey Chan*

cc @rafaelfranca @guilleiguaran

:cry: :gun: