Skip to content

Commit

Permalink
non json cookie bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lanesCSO committed Apr 8, 2024
1 parent 4b904cf commit 5f1a47b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/js/api.plugin.cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ Cookies.setJSON = function (cookieName, data, cookieOptions) {
Cookies.set(cookieName, JSON.stringify(data), cookieOptions);
}


Cookies.getJSON = function (cookieName) {
var cookieValue = Cookies.get(cookieName);
if (cookieValue) {
return JSON.parse(cookieValue)
try {
return JSON.parse(cookieValue)
} catch (error) {
Cookies.remove(cookieName);
console.warn(["invalid cookie removed", cookieName, error])
return null;
}

}
else {
return cookieValue
Expand Down
2 changes: 1 addition & 1 deletion src/js/api.plugin.cookie.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5f1a47b

Please sign in to comment.