Cookies
https://x.com/LumiTeh / https://www.lumiteh.com/ / https://github.com/LumiTeh-hub
Overview
Cookies provide a flexible way to authenticate your sessions in LumiTeh. While using the secure vault is recommended for credential management, cookies offer an alternative approach that can be more convenient for certain use cases.
Uploading Cookies to Your Session
Here’s how to upload cookies to your LumiTeh session:
from lumiteh_sdk import LumiTehClient
# Upload cookies for github.com to automatically login
cookies = [
dict(
name="sb-db-auth-token",
value="base64-cookie-value",
domain="github.com",
path="/",
expires=9778363203.913704,
httpOnly=False,
secure=False,
sameSite="Lax"
)
]
# create a new session
lumiteh = LumiTehClient()
with lumiteh.Session() as session:
_ = session.set_cookies(cookies=cookies) # can also set cookie_file="path/to/cookies.json"
# Use the cookies in your session
agent = lumiteh.Agent(session=session, max_steps=5)
res = agent.run(
task="go to lumitehlabs/lumiteh repo and get info. Fail if not logged in",
url="https://github.com/lumitehlabs/lumiteh",
)
# or get the cookies from the session
cookies_resp = session.get_cookies()
Important Notes
The cookies file must be a valid JSON file
Cookies are available for all sessions started after upload
You need to manage cookie expiration manually
Upload new cookies when they expire
Extracting Cookies from Your Browser
Here’s a step-by-step guide to extract cookies from your browser:
Of course, you can also retrieve them from your LumiTeh session:
Best Practices
SecurityStore cookie files securely
Don’t commit cookie files to version control
Regularly rotate cookies for sensitive services
MaintenanceMonitor cookie expiration dates
Set up reminders to refresh cookies
Keep backup copies of valid cookies
TroubleshootingIf a session fails, try uploading fresh cookies
Check if cookies are still valid
Verify the cookie file format is correct
Last updated