From c1e0d6031568c879c939cfce8daf46b50fe7c605 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Thu, 23 Dec 2010 10:53:10 +0000 Subject: [PATCH] SessionLifetime config setting --- Builder/IISMainHandler/build.txt | 2 +- Common/Config.cs | 3 +++ IISMainHandler/WebContext.cs | 2 +- IISMainHandler/handlers/request/LoginHandler.cs | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index e259f68..645efcf 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1863 \ No newline at end of file +1865 \ No newline at end of file diff --git a/Common/Config.cs b/Common/Config.cs index 6129667..13ff7ed 100644 --- a/Common/Config.cs +++ b/Common/Config.cs @@ -41,6 +41,8 @@ namespace FLocal.Common { public readonly int MinPostId; + public readonly int SessionLifetime; + protected Config(NameValueCollection data) : base(data) { this.InitTime = DateTime.Now.ToLongTimeString(); this.mainConnection = new MySQLConnector.Connection(data["ConnectionString"], MySQLConnector.PostgresDBTraits.instance); @@ -58,6 +60,7 @@ namespace FLocal.Common { this.AdditionalHosts = new HashSet(from host in data["AdditionalHosts"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries) select host.Trim()); this.CookiesPrefix = data["CookiesPrefix"]; this.MinPostId = int.Parse(data["MinPostId"]); + this.SessionLifetime = int.Parse(data["SessionLifetime"]); } public static void Init(NameValueCollection data) { diff --git a/IISMainHandler/WebContext.cs b/IISMainHandler/WebContext.cs index 4b98358..edebf44 100644 --- a/IISMainHandler/WebContext.cs +++ b/IISMainHandler/WebContext.cs @@ -144,7 +144,7 @@ namespace FLocal.IISHandler { session.updateLastActivity(lastUrl); HttpCookie newCookie = this.createCookie(Config.instance.CookiesPrefix + "_session"); newCookie.Value = session.sessionKey; - newCookie.Expires = DateTime.Now.AddDays(3); + newCookie.Expires = DateTime.Now.AddSeconds(Config.instance.SessionLifetime); this.httpresponse.AppendCookie(newCookie); this.session = session; } catch(NotFoundInDBException) { diff --git a/IISMainHandler/handlers/request/LoginHandler.cs b/IISMainHandler/handlers/request/LoginHandler.cs index 96da78f..28c2bce 100644 --- a/IISMainHandler/handlers/request/LoginHandler.cs +++ b/IISMainHandler/handlers/request/LoginHandler.cs @@ -45,7 +45,7 @@ namespace FLocal.IISHandler.handlers.request { HttpCookie sessionCookie = context.createCookie(Config.instance.CookiesPrefix + "_session"); sessionCookie.Value = session.sessionKey; - sessionCookie.Expires = DateTime.Now.AddDays(3); + sessionCookie.Expires = DateTime.Now.AddSeconds(Config.instance.SessionLifetime); context.httpresponse.AppendCookie(sessionCookie); context.session = session;