session.h
1 /*
2  * <one line to give the program's name and a brief idea of what it does.>
3  * Copyright (C) 2023 Jose F Rivas C <email>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef NAF_EXTRAS_SESSION
20 #define NAF_EXTRAS_SESSION
21 
22 
23 #include <string>
24 
25 #include "Poco/Random.h"
26 #include <Poco/Net/HTTPCookie.h>
27 #include <Poco/DateTime.h>
28 #include "Poco/DigestStream.h"
29 #include "Poco/MD5Engine.h"
30 
31 
32 namespace NAF
33 {
34  namespace Extras
35  {
36  class Session;
37  }
38 }
39 
40 using namespace Poco;
41 using namespace Poco::Net;
42 
43 
45 {
46  public:
47  Session();
48  virtual ~Session();
49 
50  std::string get_id() const
51  {
52  return id_;
53  }
54  std::string get_path() const
55  {
56  return path_;
57  }
58  std::string get_user() const
59  {
60  return user_;
61  }
62  int get_max_age() const
63  {
64  return max_age_;
65  }
66 
67  void set_id(std::string id)
68  {
69  id_ = id;
70  }
71  void set_path(std::string path)
72  {
73  path_ = path;
74  }
75  void set_user(std::string user)
76  {
77  user_ = user;
78  }
79  void set_max_age(int max_age)
80  {
81  max_age_ = max_age;
82  }
83 
84  void GenerateNewSessionID_();
85 
86  protected:
87  void GenerateSessionID_();
88  void GenerateMD5Hash_();
89 
90  private:
91  std::string id_;
92  std::string path_;
93  std::string user_;
94  int max_age_;
95 };
96 
97 
98 #endif // NAF_EXTRAS_SESSION
Definition: session.h:45