PET::Session |
This is a base session implementation. It works by default, but there are many implementing classes. This one uses Storable to freeze/thaw data, and stores session data to disk at $BASEPATH/sessions
Implementing classes usually only override store and load. Check out the implementations for an example! There are standard session classes shipped with PET.
| PET:: | This is a base session implementation. |
| Variables | |
| $DISP | |
| $CLEANUP_THRESHOLD | |
| $SESSION_FILE_EXPIRES | |
| Functions | |
| new | Create instance. |
| init (%params) | Init is called from new. |
| start | This method is called at each page. |
| access ($stored) | Signal access to session. |
| createName | Create the name of the session cookie and returns it. |
| thaw | Thaw the session object from “binary data”. |
| freeze | Freeze hashref to binary data. |
| store | Serialize and save session data. |
| imvalidate () | Invalidate cookie by deleting it from disk. |
| invalidate | |
| finish | |
| load | |
| get | |
| set | |
| sessionChanged | Set or get value of “SESSION_CHANGED”, which shows if the session should be synced. |
| getSesid | Return SESID. |
| onStart | Get or set SUB that is called on session creation. |
| cleanupOld | Called conditionally from “start” when a (new) cookie is created. |
sub init
Init is called from new. Some implementations might need some basic init-phase stuff.
sub freeze
Freeze hashref to binary data. See also thaw.
sub onStart
Get or set SUB that is called on session creation.
If you call onStart with a subref, it will be stored, and later at any time when a session is initialized, that subref is called upon. This way you can attach actions to session creation -- this actually is a method to set up a callback.
Usually you want to call onStart from you API at INIT time!
our $DISP
our $CLEANUP_THRESHOLD
our $SESSION_FILE_EXPIRES
Create instance.
sub new
Init is called from new.
sub init
This method is called at each page.
sub start
Signal access to session.
sub access
Create the name of the session cookie and returns it.
sub createName
Thaw the session object from “binary data”.
sub thaw
Freeze hashref to binary data.
sub freeze
Serialize and save session data.
sub store
sub invalidate
sub finish
sub load
sub get
sub set
Set or get value of “SESSION_CHANGED”, which shows if the session should be synced.
sub sessionChanged
Return SESID.
sub getSesid
Get or set SUB that is called on session creation.
sub onStart
Called conditionally from “start” when a (new) cookie is created.
sub cleanupOld