Main  /  Edit  /  History  /   /  Users Area

cppcms::session_interface

Role

This class is used for working with sessions.

Header: #include <cppcms/session_interface.h>

Generally you access session_interface class via session member of worker_thread or application.

In order to use it, sessions should be enabled in CppCMS configuration.

Managing values in session

Session is build like std::map dictionary -- key value pairs, where both key and value are std::string.

Note: all keys starting with underscore "_" are reserved for cppcms engine use.

You can set or get any other values using automatic conversion using boost::lexical_cast.

Working with client side programming.

In many cases it is useful to make session values be accessible by client-side -- javascript. CppCMS sessions provide simple API to expose certain values to client side using cookies.

Controlling session expiration

Expiration policy

Session interface supports three types of expiration

Default behavior and default timeout can be configured in CppCMS configuration file.

Changing defaults:

Note: CppCMS v0.0.2 requires set non-default expiration lifetime and method each time you access session object. This policy has changed in next versions. Timeout period is stored withing session and should be reset to default if user wants to change it.

Hi. I have some suggestions: 1)For the tutorial, put all codes which are supposed to appear together in one cpp file or header file together at the end of the tutorial and make sure that line numbers do not start from 1. 2. 3. again in each section of tutorial. Currently, it is not clear where a function or a file begins and ends because there are broken pieces of codes and all being with 1. 2. 3. 2)I am not familiar with web programing. I think people like me prefer to use cpp files to wrap html codes or probably there are good html "designer", like GUI designers, that produces the code and I can copy-paste for the "view" in CMV.


Navigation

Main Page



Valid CSS | Valid XHTML 1.0