I am using BotD for bot detection, and trying to figure out how to save the result into a cookie.
(I am sure this is simple, but im still trying to learn JS and stuck here)
Initial code:
<script>
// Initialize an agent at application startup, once per page/app.
const botdPromise = import('https://openfpcdn.io/botd/v1').then((Botd) => Botd.load())
// Get detection results when you need them.
botdPromise
.then((botd) => botd.detect())
.then((result) => console.log(result))
.catch((error) => console.error(error))
</script>
I tried:
<script>
// Initialize an agent at application startup, once per page/app.
const botdPromise = import('https://openfpcdn.io/botd/v1').then((Botd) => Botd.load())
// Get detection results when you need them.
botdPromise
.then((botd) => botd.detect())
.then(result => {
console.log(result)
document.cookie ="botd="+result+"; path=/; secure; SameSite=strict";
})
.catch((error) => console.error(error))
</script>
It prints correctly on console with "Object { bot: false }", but the cookie just says [object Object]
Any help with an example of how to get it to work would be appreciated.
Thanks,