-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSessions.h
More file actions
57 lines (49 loc) · 1.46 KB
/
Sessions.h
File metadata and controls
57 lines (49 loc) · 1.46 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
#ifndef _MONGOOSE_SESSIONS_H
#define _MONGOOSE_SESSIONS_H
#include "Request.h"
#include "Session.h"
#include "Mutex.h"
using namespace std;
/**
* A session contains the user specific values
*/
namespace Mongoose
{
class Sessions
{
public:
Sessions(string key = "sessid");
virtual ~Sessions();
/**
* Gets the session ID of a certain request,
* this will look in the cookies and create it if
* necessary
*
* @param Request the request
* @param Response the response in which the cookie should be write
*
* @return string the session ID for this request
*/
string getId(Request &request, Response &response);
/**
* Gets the session for a certain request
*
* @param Request the request
* @param Response the response inwhich the cookie should be write
*
* @return Session the session corresponding
*/
Session &get(Request &request, Response &response);
/**
* Remove all the sessions older than age
*
* @param int the age of the too old sessions in second
*/
void garbageCollect(int oldAge = 3600);
protected:
map<string, Session*> sessions;
string key;
Mutex mutex;
};
}
#endif