How to handle sessions and cookies in RT lib code?


I’ve integrated 2 factor authentication in the RT REST API 2.0, however, I would like the API to sustain a session for 24 hours after a successful login.
For logging in I just need to check the request for a session cookie and use the login_from_cookie subroutine.
Could someone please point me in the general direction of how to go about handing out a cookie and registering a new session upon a successful authentication?

Thanks in advance.