![]() |
![]()
| ![]() |
![]()
NAMEDancer2::Session::DBIC - DBIx::Class session engine for Dancer2VERSION0.120DESCRIPTIONThis module implements a session engine for Dancer2 by serializing the session, and storing it in a database via DBIx::Class.JSON was chosen as the default serialization format, as it is fast, terse, and portable. SYNOPSISExample configuration:session: "DBIC" engines: session: DBIC: dsn: "DBI:mysql:database=testing;host=127.0.0.1;port=3306" # DBI Data Source Name schema_class: "Interchange6::Schema" # DBIx::Class schema user: "user" # Username used to connect to the database password: "password" # Password to connect to the database resultset: "MySession" # DBIx::Class resultset, defaults to Session id_column: "my_session_id" # defaults to sessions_id data_column: "my_session_data" # defaults to session_data serializer: "YAML" # defaults to JSON Or if you are already using Dancer2::Plugin::DBIC and want to use its existing configuration for a database section named 'default' with all else set to default in this module then you could simply use: session: "DBIC" engines: session: DBIC: db_connection_name: default SESSION EXPIRATIONA timestamp field that updates when a session is updated is recommended, so you can expire sessions server-side as well as client-side.This session engine will not automagically remove expired sessions on the server, but with a timestamp field as above, you should be able to to do this manually. ATTRIBUTESschema_classDBIx::Class schema class, e.g. Interchange6::Schema.db_connection_nameThe Dancer2::Plugin::DBIC database connection name.If this option is provided then "schema_class", "dsn", "user" and "password" are all ignored. resultsetDBIx::Class resultset, defaults to "Session".id_columnColumn for session id, defaults to "sessions_id".If this column is not the primary key of the table, it should have a unique constraint added to it. See "add_unique_constraint" in DBIx::Class::ResultSource. data_columnColumn for session data, defaults to "session_data".dsnDBI dsn to connect to the database.userDatabase username.passwordDatabase password.schemaDBIx::Class schema.serializerSerializer to use, defaults to JSON.Dancer2::Session::DBIC provides the following serializer classes:
If you do not use the default JSON serializer then you might need to install additional modules - see the specific serializer class for details. You can also use your own serializer class by passing the fully-qualified class name as argument to this option, e.g.: MyApp::Session::Serializer serializer_objectVivified "serializer" object.serialize_optionsOptions to be passed to the constructor of the "serializer" class as a hash reference.deserialize_optionsOptions to be passed to the constructor of the "deserializer" class as a hash reference.METHODS_flushWrite the session to the database. Returns the session object._retrieve($id)Look for a session with the given id.Returns the session object if found, "undef" if not. Dies if the session was found, but could not be deserialized. _change_id( $old_id, $new_id )Change ID of session with $old_id to <$new_id>._destroy()Remove the current session object from the database.SEE ALSODancer2, Dancer2::SessionAUTHORStefan Hornburg (Racke) <racke@linuxia.de>ACKNOWLEDGEMENTSBased on code from Dancer::Session::DBI written by James Aitken and code from Dancer::Plugin::DBIC written by Naveed Massjouni.Peter Mottram, support for JSON, YAML, Sereal and custom serializers, GH #8, #9, #11, #12. Also for adding _change_id method and accompanying tests. Rory Zweistra, GH #9. Andy Jack, GH #2. COPYRIGHT AND LICENSEThis software is copyright (c) Stefan Hornburg.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|