You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a cookie is set on a parent domain and is expected to be overwritten in a sub domain, the parent domains cookie is always returned. This bit us due to some weirdnesses with a CEF web window, and we have a work around but it seems like it could come back to bite us again.
Extending the cookie 'get' to allow for passing in a flag to read the last cookie with the given name.
// pseudo code
Cookies.get(name, {last: true});
function get(name, options) {
if (typeof document === 'undefined' || (arguments.length && !name)) {
return
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all.
var cookies = document.cookie ? document.cookie.split('; ') : []
var jar = {}
var findingLast = options ? options.last : false;
for (var i = 0; i < cookies.length; i++) {
var parts = cookies[i].split('=')
var value = parts.slice(1).join('=')
try {
var found = decodeURIComponent(parts[0])
if (!(found in jar) || findingLast) jar[found] = converter.read(value, found)
if (name === found && !findingLast) {
break
}
} catch (e) {
// Do nothing...
}
}
return name ? jar[name] : jar
}
Alternative Solution
A Cookies.getAll which allows us to retrieve all of the cookies with the given name.
This would allow developers to use the most appropriate cookie (for example by encoding a date or version into the cookie value)
The text was updated successfully, but these errors were encountered:
Semi related to this issue:
#226
When a cookie is set on a parent domain and is expected to be overwritten in a sub domain, the parent domains cookie is always returned. This bit us due to some weirdnesses with a CEF web window, and we have a work around but it seems like it could come back to bite us again.
For example
Proposed Solution
Extending the cookie 'get' to allow for passing in a flag to read the last cookie with the given name.
Alternative Solution
A
Cookies.getAll
which allows us to retrieve all of the cookies with the given name.This would allow developers to use the most appropriate cookie (for example by encoding a date or version into the cookie value)
The text was updated successfully, but these errors were encountered: