Lona has built-in, HTTP cookie based session system that provides user sessions without login. This makes personal daemonized views possible.
Settings: Session Settings
from lona import LonaView
def handle_request(self, request):
print(request.user) # prints "<AnonymousUser(CUiUvxtCHxEMMobEqqqDeqtsjMyu)>"
If settings.SESSIONS is enabled, the middleware lona.middleware.sessions.SessionMiddleware checks if a cookie with the name specified in settings.SESSIONS_KEY_NAME is set. If not, the middleware generates a random key using settings.SESSIONS_KEY_GENERATOR, sets the cookie and triggers an HTTP reload to make the browser return with the newly set cookie.
When the session key is present, the middleware sets up a lona.middleware.sessions.AnonymousUser with the session key set in request.user.
The cookie setting and redirecting workflow is skipped on non-interactive views to make REST APIs work as expected