How do i use createAuthCookie outside of better auth context?

If i create a plugin i have the following available to me in the plugin:
ctx.context.createAuthCookie("session_token")

How would I get access to this createAuthCookie in my own controller?

I am creating guest sessions for non logged in users and I am using a middleware to generate the session and cookie if there is not one for the request. I wrote a plugin that generates the session and cookie which is available at a better auth endpoint but I can only use that by calling the endpoint from my client.

What if I need that functionality on a request that goes through my controller or middleware?
Was this page helpful?