add undefined check on jsonString

I try to use keepStateInCookie but it gave me "JSON.parse: unexpected character at line 1 column 1 of the JSON data" error in the console although the jsonString has empty value. Adding check for undefined with jsonString fixes it. This is tested on Windows 7 and Firefox 30 browser.