-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSession.h
More file actions
71 lines (60 loc) · 1.72 KB
/
Session.h
File metadata and controls
71 lines (60 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef _MONGOOSE_SESSION_H
#define _MONGOOSE_SESSION_H
#include <map>
#include "Mutex.h"
using namespace std;
/**
* A session contains the user specific values
*/
namespace Mongoose
{
class Session
{
public:
Session();
/**
* Sets the value of a session variable
*
* @param string the name of the variable
* @param string the value of the variable
*/
void setValue(string key, string value);
/**
* Unset a session varaible
*
* @param string the variable name
*/
void unsetValue(string key);
/**
* Check if the given variable exists
*
* @param string the name of the variable
*/
bool hasValue(string key);
/**
* Try to get the value for the given variable
*
* @pram string the name of the variable
* @param string the fallback value
*
* @return string the value of the variable if it exists, fallback else
*/
string get(string key, string fallback = "");
/**
* Pings the session, this will update the creation date to now
* and "keeping it alive"
*/
void ping();
/**
* Returns the session age, in seconds
*
* @return int the number of sessions since the last activity of the session
*/
int getAge();
protected:
map<string, string> values;
int date;
Mutex mutex;
};
}
#endif