Dancer::Session::Abstract(3pm) | User Contributed Perl Documentation | Dancer::Session::Abstract(3pm) |
Dancer::Session::Abstract - abstract class for session engine
version 1.3521
This virtual class describes how to build a session engine for Dancer. This is done in order to allow multiple session storage backends with a common interface.
Any session engine must inherit from Dancer::Session::Abstract and implement the following abstract methods.
These settings control how a session acts.
session_name
The default session name is "dancer_session". This can be set in your config file:
setting session_name: "mydancer_session"
session_domain
Allows you to set the domain property on the cookie, which will override the default. This is useful for setting the session cookie's domain to something like ".domain.com" so that the same cookie will be applicable and usable across subdomains of a base domain.
session_secure
The user's session id is stored in a cookie. If true, this cookie will be made "secure" meaning it will only be served over https.
session_expires
When the session should expire. The format is either the number of seconds in the future, or the human readable offset from "expires" in Dancer::Cookie.
By default, there is no expiration.
session_is_http_only
This setting defaults to 1 and instructs the session cookie to be created with the "HttpOnly" option active, meaning that JavaScript will not be able to access to its value.
You should probably not override this; the user can control the cookie name using the "session_name" setting.
The following methods are not supposed to be overloaded, they are generic and should be OK for each session engine.
Then, the filter looks for a cookie named "dancer.session" (or whatever you've set the "session_name" setting to, if you've used it) in order to retrieve the current session object. If not found, a new session object is created and its id written to the cookie.
Whenever a session call is made within a route handler, the singleton representing the current session object is modified.
A flush is made to the session object after every modification unless the session engine overrides the "is_lazy" method to return true.
Dancer Core Developers
This software is copyright (c) 2010 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2023-02-10 | perl v5.36.0 |