Hello,
how can I manage cookies with UI Bakery?
“$cookies” library isn’t available.
thank you,
Loïc.
Hello,
how can I manage cookies with UI Bakery?
“$cookies” library isn’t available.
thank you,
Loïc.
Hello @Loic_Madies!
You can use a standard API in a browser in a Code step in UI Bakery.
Check it out -> https://developer.mozilla.org/docs/Web/API/Document/cookie
For example:
document.cookie = ‘name=jhon’;
console.log(document.cookie);
Hi @Loic_Madies!
Thank you for the great question!
You can use standard browser API inside UI Bakery Code Step.
For example, as @ev_jennie explained.
document.cookie = ‘name=jhon’;
console.log(document.cookie);
Thank you a lot for your responses.
“document.cookies” is very useful but doesn’t provide “getCookie” function.
Something like that works:
var match = document.cookie.match(new RegExp(’(^| )’ + “name” + ‘=([^;]+)’));
if (match) console.log(match[2]);
But it isn’t really readable-friendly. Can I declare a global function “getCookies” with the two previous lines in UI Bakery and use it into my “Code ACTION” ?
Thank you again.
For the moment, we don’t have such a mechanism, but you can do something like that:
window.getCookies = function() {…}
…
const cookies = window.getCookies()
Ok thank you