diff --git a/modules/web/database/http_session_manager_db.cpp b/modules/web/database/http_session_manager_db.cpp index 280c1dd5f..b2a70f0d1 100644 --- a/modules/web/database/http_session_manager_db.cpp +++ b/modules/web/database/http_session_manager_db.cpp @@ -117,14 +117,14 @@ Ref HTTPSessionManagerDB::delete_session(const String &session_id) return s; } - if (!s->id) { + if (!s->get_id()) { return s; } Ref b = get_query_builder(); - b->del(_database_data_table_name)->where()->wpi("session_db_id", s->id)->end_command(); - b->del(_database_table_name)->where()->wpi("id", s->id)->end_command(); + b->del(_database_data_table_name)->where()->wpi("session_db_id", s->get_id())->end_command(); + b->del(_database_table_name)->where()->wpi("id", s->get_id())->end_command(); b->run_query(); return s; @@ -133,21 +133,21 @@ Ref HTTPSessionManagerDB::delete_session(const String &session_id) void HTTPSessionManagerDB::save_session(Ref session) { Ref b = get_query_builder(); - if (!session->id) { + if (!session->get_id()) { b->insert(_database_table_name, "session_id"); b->values(); - b->vals(session->session_id); + b->vals(session->get_session_id()); b->cvalues(); b->end_command(); b->select_last_insert_id(); - session->id = b->run()->get_last_insert_rowid(); + session->set_id(b->run()->get_last_insert_rowid()); b->reset(); } - b->del(_database_data_table_name)->where()->wpi("session_db_id", session->id)->end_command(); - int id = session->id; + b->del(_database_data_table_name)->where()->wpi("session_db_id", session->get_id())->end_command(); + int id = session->get_id(); HashMap *m = session->get_data(); @@ -188,9 +188,9 @@ void HTTPSessionManagerDB::load_sessions() { Ref s; s.instance(); - s->id = id; + s->set_id(id); - s->session_id = session_id; + s->set_session_id(session_id); add_session(s); } @@ -210,7 +210,7 @@ void HTTPSessionManagerDB::load_sessions() { for (int i = 0; i < _sessions_vec.size(); ++i) { Ref ss = _sessions_vec[i]; - if (ss.is_valid() && session_db_id == ss->id) { + if (ss.is_valid() && session_db_id == ss->get_id()) { s = ss; break; } diff --git a/modules/web/http/http_session.h b/modules/web/http/http_session.h index 07347f712..0cbf34e7e 100644 --- a/modules/web/http/http_session.h +++ b/modules/web/http/http_session.h @@ -77,12 +77,12 @@ public: HTTPSession(); ~HTTPSession(); - String session_id; - int id; - protected: static void _bind_methods(); + String session_id; + int id; + Mutex _mutex; HashMap _data; diff --git a/modules/web/http/http_session_manager.cpp b/modules/web/http/http_session_manager.cpp index 04309432b..39a65b476 100644 --- a/modules/web/http/http_session_manager.cpp +++ b/modules/web/http/http_session_manager.cpp @@ -50,7 +50,7 @@ void HTTPSessionManager::add_session(Ref session) { _mutex.lock(); _sessions_vec.push_back(session); - _sessions[session->session_id] = session; + _sessions[session->get_session_id()] = session; _mutex.unlock(); } @@ -60,7 +60,7 @@ void HTTPSessionManager::remove_session(Ref session) { _mutex.lock(); - _sessions.erase(session->session_id); + _sessions.erase(session->get_session_id()); for (int i = 0; i < _sessions_vec.size(); ++i) { if (_sessions_vec[i] == session) { @@ -83,7 +83,7 @@ Ref HTTPSessionManager::delete_session(const String &session_id) { for (int i = 0; i < _sessions_vec.size(); ++i) { Ref sess = _sessions_vec[i]; - if (sess->session_id == session_id) { + if (sess->get_session_id() == session_id) { _sessions_vec.remove(i); break; @@ -107,13 +107,13 @@ Ref HTTPSessionManager::create_session() { session.instance(); while (true) { - session->session_id = generate_session_id(session->session_id); + session->set_session_id(generate_session_id(session->get_session_id())); _mutex.lock(); - if (_sessions[session->session_id] == nullptr) { + if (_sessions[session->get_session_id()] == nullptr) { _sessions_vec.push_back(session); - _sessions[session->session_id] = session; + _sessions[session->get_session_id()] = session; _mutex.unlock();