public bool sessionToDatabase(SessionItem session) { Debug.WriteLine("Accessesd by Database handler: ip: " + session.getSession()["ipaddress"] + " id:" + session.getSession().SessionID); try { if (MySqlConnection.State == System.Data.ConnectionState.Open) { MySqlCommand command = new MySqlCommand("INSERT INTO sessions (sessionid, ipaddress, username) VALUES(?id, ?ip, ?user);", MySqlConnection); command.Parameters.AddWithValue("?id", session.getSession().SessionID); command.Parameters.AddWithValue("?ip", HttpContext.Current.Session["ipaddress"]); command.Parameters.AddWithValue("?user", HttpContext.Current.Session["username"]); command.ExecuteNonQuery(); return true; } else { MySqlCommand command = new MySqlCommand("INSERT INTO sessions (sessionid, ipaddress, username) VALUES(?id, ?ip, ?user);", MySqlConnection); command.Parameters.AddWithValue("?id", session.getSession().SessionID); command.Parameters.AddWithValue("?ip", session.getSession()["ipaddress"].ToString()); command.Parameters.AddWithValue("?user", HttpContext.Current.Session["username"]); command.Connection.Open(); command.ExecuteNonQuery(); return true; } } catch (MySqlException exp) { GlobalHandlers.Debugger.write(exp.ToString()); return false; } }
public bool addToList(SessionItem sess) { Session_List.Add(sess); return true; }