I'm currently trying to implement my own authentication with the crypto module and astro.cookies.
As of right now in my login api route, it compares the password in the request with the hashed password stored in my db. Now I want to create a session and store it as a cookie on the client but I'm unsure of how that works. How should I create a session and store it in my postgres db?
This is my current code: https://sourceb.in/kdU2sEmtAr
Can I just generate a random string as session id and store that in my database with the userid and in the cookie? If so how would I make my database automatically delete the row when the maxAge is hit?