1Dancer::Session::AbstraUcste(r3)Contributed Perl DocumenDtaantcieorn::Session::Abstract(3)
2
3
4
6 Dancer::Session::Abstract - abstract class for session engine
7
9 version 1.3512
10
12 This virtual class describes how to build a session engine for Dancer.
13 This is done in order to allow multiple session storage backends with a
14 common interface.
15
16 Any session engine must inherit from Dancer::Session::Abstract and
17 implement the following abstract methods.
18
19 Configuration
20 These settings control how a session acts.
21
22 session_name
23
24 The default session name is "dancer_session". This can be set in your
25 config file:
26
27 setting session_name: "mydancer_session"
28
29 session_domain
30
31 Allows you to set the domain property on the cookie, which will
32 override the default. This is useful for setting the session cookie's
33 domain to something like ".domain.com" so that the same cookie will be
34 applicable and usable across subdomains of a base domain.
35
36 session_secure
37
38 The user's session id is stored in a cookie. If true, this cookie will
39 be made "secure" meaning it will only be served over https.
40
41 session_expires
42
43 When the session should expire. The format is either the number of
44 seconds in the future, or the human readable offset from "expires" in
45 Dancer::Cookie.
46
47 By default, there is no expiration.
48
49 session_is_http_only
50
51 This setting defaults to 1 and instructs the session cookie to be
52 created with the "HttpOnly" option active, meaning that JavaScript will
53 not be able to access to its value.
54
55 Abstract Methods
56 retrieve($id)
57 Look for a session with the given id, return the session object if
58 found, undef if not.
59
60 create()
61 Create a new session, return the session object.
62
63 flush()
64 Write the session object to the storage engine.
65
66 destroy()
67 Remove the current session object from the storage engine.
68
69 session_name (optional)
70 Returns a string with the name of cookie used for storing the
71 session ID.
72
73 You should probably not override this; the user can control the
74 cookie name using the "session_name" setting.
75
76 get_value($key)
77 Retrieves the value associated with the key.
78
79 set_value($key, $value)
80 Stores the value associated with the key.
81
82 Inherited Methods
83 The following methods are not supposed to be overloaded, they are
84 generic and should be OK for each session engine.
85
86 build_id
87 Build a new uniq id.
88
89 read_session_id
90 Reads the session ID from the cookie, ensuring it's syntactically
91 valid.
92
93 write_session_id
94 Write the current session id to the "dancer.session" cookie.
95
96 is_lazy
97 Default is false. If true, session data will not be flushed after
98 every modification and the session engine (or application) will
99 need to ensure that a flush is called before the end of the
100 request.
101
103 role
104 A Dancer::Session object represents a session engine and should
105 provide anything needed to manipulate a session, whatever its
106 storing engine is.
107
108 id The session id will be written to a cookie, by default named
109 "dancer.session", it is assumed that a client must accept cookies
110 to be able to use a session-aware Dancer webapp. (The cookie name
111 can be change using the "session_name" config setting.)
112
113 storage engine
114 When the session engine is enabled, a before filter takes care to
115 initialize the appropriate session engine (according to the setting
116 "session").
117
118 Then, the filter looks for a cookie named "dancer.session" (or
119 whatever you've set the "session_name" setting to, if you've used
120 it) in order to retrieve the current session object. If not found,
121 a new session object is created and its id written to the cookie.
122
123 Whenever a session call is made within a route handler, the
124 singleton representing the current session object is modified.
125
126 A flush is made to the session object after every modification
127 unless the session engine overrides the "is_lazy" method to return
128 true.
129
131 Dancer Core Developers
132
134 This software is copyright (c) 2010 by Alexis Sukrieh.
135
136 This is free software; you can redistribute it and/or modify it under
137 the same terms as the Perl 5 programming language system itself.
138
139
140
141perl v5.30.0 2019-07-26 Dancer::Session::Abstract(3)