Difference "cppcms::session_interface" ver. 2 versus ver. 3
Content:
## Role |
|
This class is used for working with sessions. |
|
Header: `#include <cppcms/session_interface.h>` |
|
Generaly you access `session_interface` class via `session` member of `worker_thread` or `application`. |
Generally you access `session_interface` class via `session` member of `worker_thread` or `application`. |
|
## 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`. |
|
- **`bool is_set(string const &key)`** check if key `key` exists in session. |
- **`void del(string const &key)`** -- remove key from session. |
- **`std::string &operator[](string const &key)`** -- return reference to value for key. If key not exists it is created. |
- **`template<typename T> T get(string const key)`** -- convert value to type T from string and return it. If conversion fails, `boost::bad_lexical_cast` is thrown. |
- **`template<typename T> void set(string const &key,T const &val)`** -- convert value from T to string and assign it to key. |
- **`void get(string const &key,serializable &);`** -- save serializable object to session. See: [`cppcms::serializable`](/wikipp/en/page/ref_cppcms_serializable). |
- **`void set(string const &key,serializable const &);`** -- fetch serializable object from session. See: [`cppcms::serializable`](/wikipp/en/page/ref_cppcms_serializable) |
- **`void clear()`** -- clear session -- remove it. |
|
About
CppCMS is a web development framework for performance demanding applications.
Support This Project
Navigation
Main Page
Valid CSS
| Valid XHTML 1.0