Andy
Andy
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
All good, got it to work by following steps of another plugin
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
I can see the cookies in the browser, they're just not being verified by better-auth / extracting the session data out of them
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
Would anyone have an example of how this could be done and for it to be recognised correctly?
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
Hi, is there any help with this - it seems that I'm incorrectly signing the cookies so everytime i try to use the getSession it fails. I can't find anywhere where it states how to create your own cookies/session/users by using an alternative authentication logic route.
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
Sorry - but im super confused I have no idea what you mean, is there an easier way of doing this? I can see that there is a ctx.context.createAuthCookie() but its not very well documented here: https://www.better-auth.com/docs/concepts/plugins#endpoints and cuts off. This is the exact line:
createAuthCookie: This is a helper function that let's you get a cookie name and options for either to set or get cookies. It implements things like __secure prefix and __host prefix for cookies based on
createAuthCookie: This is a helper function that let's you get a cookie name and options for either to set or get cookies. It implements things like __secure prefix and __host prefix for cookies based on
Would it be possible for anyone to provide an example of using this function? I have looked at the source code for better-call and this seems to be creating the two-factor cookie:
const cookieName = ctx.context.createAuthCookie(TWO_FACTOR_COOKIE_NAME);
const twoFactorCookie = await ctx.getSignedCookie(
cookieName.name,
ctx.context.secret,
);
const cookieName = ctx.context.createAuthCookie(TWO_FACTOR_COOKIE_NAME);
const twoFactorCookie = await ctx.getSignedCookie(
cookieName.name,
ctx.context.secret,
);
But the createAuthCookie, doen't seem to actually create the cookie - just confused about how to do this, especially in prod, where i'm not sure if __secure-better-auth.session_token is the correct name for it
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
I would have assumed that the ctx.context.setNewSession method would be doing this already
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
I have tried that but was missing a step. I got it work by mimicking how the better-auth library signs the tokens instead here :
const signedtoken = await createHMAC("SHA-256", "base64urlnopad").sign(
ctx.context.secret,
session.token,
);

ctx.setCookie("better-auth.session_token", signedtoken, {
expires: session.expiresAt,
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "lax",
path: "/",
});

// Set the secure cookie in prod
if (process.env.NODE_ENV === "production") {
ctx.setCookie("__secure-better-auth.session_token", signedtoken, {
expires: session.expiresAt,
httpOnly: true,
secure: true,
sameSite: "lax",
path: "/",
});
}

return ctx.redirect("/");
},
const signedtoken = await createHMAC("SHA-256", "base64urlnopad").sign(
ctx.context.secret,
session.token,
);

ctx.setCookie("better-auth.session_token", signedtoken, {
expires: session.expiresAt,
httpOnly: true,
secure: process.env.NODE_ENV === "production",
sameSite: "lax",
path: "/",
});

// Set the secure cookie in prod
if (process.env.NODE_ENV === "production") {
ctx.setCookie("__secure-better-auth.session_token", signedtoken, {
expires: session.expiresAt,
httpOnly: true,
secure: true,
sameSite: "lax",
path: "/",
});
}

return ctx.redirect("/");
},
Is there an easier way than this?
12 replies
BABetter Auth
Created by Andy on 4/27/2025 in #help
Setting cookies with custom plugin auth
I can hit the endpoint and it correctly redirects me but doesn't include any Set-Cookie headers when i try to set it, neither does it include the Cookies when checking the browser storage
12 replies
TTypebot
Created by H on 8/5/2024 in #help-and-questions
Send marketing updates via WhatsApp
I haven't done it myself. What events are you specifically tracking? You can use this for google analytics: https://docs.typebot.io/editor/blocks/integrations/google-analytics Google Tag Manager at the bottom of this page https://docs.typebot.io/settings/overview You would have to look into what actions to configure for your typebot
6 replies
TTypebot
Created by H on 8/5/2024 in #help-and-questions
Send marketing updates via WhatsApp
I'd suggest you set up Google Tag Manager / Tracking and add it to the bot to track events. You can also add a simple HTTP call for specific actions to a backend server / api that you have to add them to a database > and send promotions via wattsapp that way after collecting details
6 replies
TTypebot
Created by gzanotto on 7/2/2024 in #help-and-questions
Self-hosted pricing?
https://docs.typebot.io/self-hosting/configuration If you look here: The DEFAULT_WORKSPACE_PLAN is set to FREE. You can either change this to UNLIMITED or Like H said, add the ADMIN_EMAIL as the default plan for the admin user is UNLIMITED. You may need to recreate your workspace (not sure) so make sure to export your bots before you do so.
9 replies